mirror of
https://github.com/Tencent/rapidjson.git
synced 2025-10-28 03:20:15 +01:00
Add string pattern in schema
This commit is contained in:
@@ -102,6 +102,19 @@ TEST(SchemaValidator, String_LengthRange) {
|
||||
VALIDATE(s, "\"ABCD\"", false);
|
||||
}
|
||||
|
||||
#if RAPIDJSON_SCHEMA_HAS_REGEX
|
||||
TEST(SchemaValidator, String_Pattern) {
|
||||
Document sd;
|
||||
sd.Parse("{\"type\":\"string\",\"pattern\":\"^(\\\\([0-9]{3}\\\\))?[0-9]{3}-[0-9]{4}$\"}");
|
||||
Schema s(sd);
|
||||
|
||||
VALIDATE(s, "\"555-1212\"", true);
|
||||
VALIDATE(s, "\"(888)555-1212\"", true);
|
||||
VALIDATE(s, "\"(888)555-1212 ext. 532\"", false);
|
||||
VALIDATE(s, "\"(800)FLOWERS\"", false);
|
||||
}
|
||||
#endif
|
||||
|
||||
TEST(SchemaValidator, Integer) {
|
||||
Document sd;
|
||||
sd.Parse("{\"type\":\"integer\"}");
|
||||
|
||||
Reference in New Issue
Block a user