1[ 2 { 3 "description": "Issue470Test", 4 "schema": { 5 "$schema": "http://json-schema.org/draft-07/schema#", 6 "$id": "https://example.com/issue-470.json", 7 "title": "OneOf validation message", 8 "description": "Test description", 9 "type": "object", 10 "properties": { 11 "search": { 12 "type": "object", 13 "oneOf": [ 14 { 15 "type": "object", 16 "properties": { 17 "byName": { 18 "type": "object", 19 "properties": { 20 "name": { 21 "type": "string", 22 "maxLength": 20, 23 "minLength": 1 24 } 25 }, 26 "additionalProperties": false 27 } 28 }, 29 "additionalProperties": false 30 }, 31 { 32 "type": "object", 33 "properties": { 34 "byAge": { 35 "type": "object", 36 "properties": { 37 "age": { 38 "type": "integer", 39 "maximum": 150, 40 "minimum": 1 41 } 42 }, 43 "additionalProperties": false 44 } 45 }, 46 "additionalProperties": false 47 } 48 ] 49 } 50 }, 51 "additionalProperties": false 52 }, 53 "tests": [ 54 { 55 "description": "Test valid oneOf option 1", 56 "data": { 57 "search": { 58 "byName": { 59 "name": "John" 60 } 61 } 62 }, 63 "valid": true 64 }, 65 { 66 "description": "Test valid oneOf option 2", 67 "data": { 68 "search": { 69 "byAge": { 70 "age": 35 71 } 72 } 73 }, 74 "valid": true 75 }, 76 { 77 "description": "Test invalid oneOf option 1 - wrong type", 78 "data": { 79 "search": { 80 "byName": { 81 "name": 123 82 } 83 } 84 }, 85 "valid": false, 86 "validationMessages": [ 87 "$.search: must be valid to one and only one schema, but 0 are valid", 88 "$.search: property 'byName' is not defined in the schema and the schema does not allow additional properties", 89 "$.search.byName.name: integer found, string expected" 90 ] 91 }, 92 { 93 "description": "Test invalid oneOf option 1 - invalid value", 94 "data": { 95 "search": { 96 "byName": { 97 "name": "Too loooooooooong name" 98 } 99 } 100 }, 101 "valid": false, 102 "validationMessages": [ 103 "$.search: must be valid to one and only one schema, but 0 are valid", 104 "$.search: property 'byName' is not defined in the schema and the schema does not allow additional properties", 105 "$.search.byName.name: must be at most 20 characters long" 106 ] 107 }, 108 { 109 "description": "Test invalid oneOf option 2 - wrong type", 110 "data": { 111 "search": { 112 "byAge": { 113 "age": "20" 114 } 115 } 116 }, 117 "valid": false, 118 "validationMessages": [ 119 "$.search: must be valid to one and only one schema, but 0 are valid", 120 "$.search.byAge.age: string found, integer expected", 121 "$.search: property 'byAge' is not defined in the schema and the schema does not allow additional properties" 122 ] 123 }, 124 { 125 "description": "Test invalid oneOf option 2 - invalid value", 126 "data": { 127 "search": { 128 "byAge": { 129 "age": 200 130 } 131 } 132 }, 133 "valid": false, 134 "validationMessages": [ 135 "$.search: must be valid to one and only one schema, but 0 are valid", 136 "$.search.byAge.age: must have a maximum value of 150", 137 "$.search: property 'byAge' is not defined in the schema and the schema does not allow additional properties" 138 ] 139 } 140 ] 141 } 142]