use super::Value;
#[must_use]
pub fn any_of(schemas: Vec<Value>) -> Value {
Value::Object(
[("anyOf".into(), Value::Array(schemas))]
.into_iter()
.collect(),
)
}
#[must_use]
pub fn union(schemas: Vec<Value>) -> Value {
any_of(schemas)
}
#[must_use]
pub fn one_of(schemas: Vec<Value>) -> Value {
Value::Object(
[("oneOf".into(), Value::Array(schemas))]
.into_iter()
.collect(),
)
}
#[must_use]
pub fn all_of(schemas: Vec<Value>) -> Value {
Value::Object(
[("allOf".into(), Value::Array(schemas))]
.into_iter()
.collect(),
)
}
#[must_use]
pub fn intersection(left: Value, right: Value) -> Value {
all_of(vec![left, right])
}
#[must_use]
pub fn not(schema: impl Into<Value>) -> Value {
Value::Object([("not".into(), schema.into())].into_iter().collect())
}
#[must_use]
pub fn if_then(if_schema: Value, then_schema: Value) -> Value {
Value::Object(
[("if".into(), if_schema), ("then".into(), then_schema)]
.into_iter()
.collect(),
)
}
#[must_use]
pub fn if_then_else(if_schema: Value, then_schema: Value, else_schema: Value) -> Value {
Value::Object(
[
("if".into(), if_schema),
("then".into(), then_schema),
("else".into(), else_schema),
]
.into_iter()
.collect(),
)
}