| 1 | [ |
| 2 | { |
| 3 | "description": "one property is pattern for another", |
| 4 | "schema": { |
| 5 | "properties": { |
| 6 | "shouldMatch": {}, |
| 7 | "string": {"pattern": {"$data": "1/shouldMatch"}} |
| 8 | } |
| 9 | }, |
| 10 | "tests": [ |
| 11 | { |
| 12 | "description": "a matching pattern is valid", |
| 13 | "data": { |
| 14 | "shouldMatch": "^a*$", |
| 15 | "string": "aaa" |
| 16 | }, |
| 17 | "valid": true |
| 18 | }, |
| 19 | { |
| 20 | "description": "a non-matching pattern is invalid", |
| 21 | "data": { |
| 22 | "shouldMatch": "^a*$", |
| 23 | "string": "abc" |
| 24 | }, |
| 25 | "valid": false |
| 26 | }, |
| 27 | { |
| 28 | "description": "ignores non-strings", |
| 29 | "data": { |
| 30 | "shouldMatch": "^a*$", |
| 31 | "string": 123 |
| 32 | }, |
| 33 | "valid": true |
| 34 | }, |
| 35 | { |
| 36 | "description": "fails if value of pattern is not a string", |
| 37 | "data": { |
| 38 | "shouldMatch": 123, |
| 39 | "string": "123" |
| 40 | }, |
| 41 | "valid": false |
| 42 | }, |
| 43 | { |
| 44 | "description": "valid if value of pattern is undefined", |
| 45 | "data": { |
| 46 | "string": "123" |
| 47 | }, |
| 48 | "valid": true |
| 49 | } |
| 50 | ] |
| 51 | }, |
| 52 | { |
| 53 | "description": "property values should contain their names", |
| 54 | "schema": { |
| 55 | "additionalProperties": { |
| 56 | "pattern": {"$data": "0#"} |
| 57 | } |
| 58 | }, |
| 59 | "tests": [ |
| 60 | { |
| 61 | "description": "valid property values", |
| 62 | "data": {"foo": "1foo", "bar": "bar2", "baz": "3baz4"}, |
| 63 | "valid": true |
| 64 | }, |
| 65 | { |
| 66 | "description": "invalid property values", |
| 67 | "data": {"foo": "fo"}, |
| 68 | "valid": false |
| 69 | } |
| 70 | ] |
| 71 | } |
| 72 | ] |