Commit 1062f0a4 authored by Milo Yip's avatar Milo Yip

Add allOf in schema

parent c2649a36
This diff is collapsed.
......@@ -539,3 +539,34 @@ TEST(SchemaValidator, MultiTypeWithObject) {
VALIDATE(s, "{ \"tel\": \"fail\" }", false);
}
TEST(SchemaValidator, AllOf) {
Document sd;
sd.Parse("{\"allOf\": [{ \"type\": \"string\", \"minLength\": 2 }, { \"type\": \"string\", \"maxLength\": 5 }]}");
Schema s(sd);
VALIDATE(s, "\"ok\"", true);
VALIDATE(s, "\"n\"", false);
VALIDATE(s, "\"too long\"", false);
VALIDATE(s, "123", false);
}
TEST(SchemaValidator, AllOf_Nested) {
Document sd;
sd.Parse(
"{"
" \"allOf\": ["
" { \"type\": \"string\", \"minLength\": 2 },"
" { \"type\": \"string\", \"maxLength\": 5 },"
" { \"allOf\": [ { \"enum\" : [\"ok\", \"okay\", \"OK\", \"o\"] }, { \"enum\" : [\"ok\", \"OK\", \"o\"]} ] }"
" ]"
"}");
Schema s(sd);
VALIDATE(s, "\"ok\"", true);
VALIDATE(s, "\"OK\"", true);
VALIDATE(s, "\"okay\"", false);
VALIDATE(s, "\"o\"", false);
VALIDATE(s, "\"n\"", false);
VALIDATE(s, "\"too long\"", false);
VALIDATE(s, "123", false);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment