Skip to content

Commit

Permalink
Implement folding for string constraints
Browse files Browse the repository at this point in the history
  • Loading branch information
TimDiekmann committed Oct 18, 2024
1 parent 3842c47 commit 63cfefe
Show file tree
Hide file tree
Showing 2 changed files with 862 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -403,4 +403,106 @@ mod tests {

assert_eq!(errors, actual_errors);
}

#[test]
fn intersect_typed_any_of_single() {
check_schema_intersection(
[
json!({
"anyOf": [
{
"type": "string",
"minLength": 8,
"description": "A string with a minimum length of 8 characters",
},
{
"type": "number",
"minimum": 0,
"description": "A number greater than or equal to 0",
},
]
}),
json!({
"type": "string",
"maxLength": 10,
}),
],
[json!({
"anyOf": [
{
"type": "string",
"minLength": 8,
"maxLength": 10,
"description": "A string with a minimum length of 8 characters",
}
]
})],
);
}

#[test]
fn intersect_typed_any_of_multi() {
check_schema_intersection(
[
json!({
"type": "string",
"maxLength": 10,
}),
json!({
"anyOf": [
{
"type": "string",
"minLength": 8,
},
{
"type": "string",
"maxLength": 25,
},
]
}),
],
[json!({
"anyOf": [
{
"type": "string",
"minLength": 8,
"maxLength": 10,
},
{
"type": "string",
"maxLength": 10,
},
]
})],
);

check_schema_intersection(
[
json!({
"type": "string",
"maxLength": 10,
}),
json!({
"anyOf": [
{
"type": "string",
"minLength": 8,
},
{
"type": "string",
"maxLength": 25,
},
]
}),
json!({
"type": "string",
"maxLength": 5,
}),
],
[json!({
"type": "string",
"maxLength": 5,
})],
);
}
}
Loading

0 comments on commit 63cfefe

Please sign in to comment.