1[
2  {
3    "description": "Tests that validate custom message functionality doesn't work for keywords at any level, if validator config has isCustomMessageSupported set as false",
4    "schema": {
5      "type": "object",
6      "properties": {
7        "foo": {
8          "type": "array",
9          "maxItems": 3,
10          "items" : {
11            "type" : "number"
12          },
13          "message" : {
14            "maxItems" : "Custom Message: Maximum 3 numbers can be given in 'foo'",
15            "type" : "Custom Message: Only numbers are supported in 'foo'"
16          }
17        },
18        "bar": {
19          "type": "string"
20        }
21      },
22      "message": {
23        "type" : "Custom Message: Invalid type provided"
24      }
25    },
26    "tests": [
27      {
28        "description": "Basic Success Test 1",
29        "config": {
30          "isCustomMessageSupported": false
31        },
32        "data": {
33          "foo": [],
34          "bar": "Bar 1"
35        },
36        "valid": true
37      },
38      {
39        "description": "Basic Success Test 2",
40        "config": {
41          "isCustomMessageSupported": false
42        },
43        "data": {
44          "foo": [1, 2],
45          "bar": "Bar 1"
46        },
47        "valid": true
48      },
49      {
50        "description": "Custom error message for keyword failing at top level - type keyword",
51        "config": {
52          "isCustomMessageSupported": false
53        },
54        "data": {
55          "foo": [1, 2, 3],
56          "bar": 123
57        },
58        "valid": false,
59        "validationMessages": [
60          "$.bar: integer found, string expected"
61        ]
62      },
63      {
64        "description": "Custom error message for keyword failing at nested property level - type keyword",
65        "config": {
66          "isCustomMessageSupported": false
67        },
68        "data": {
69          "foo": [1, 2, "text"],
70          "bar": "Bar 1"
71        },
72        "valid": false,
73        "validationMessages": [
74          "$.foo[2]: string found, number expected"
75        ]
76      },
77      {
78        "description": "Custom error message for keyword failing at nested property level - maxItems keyword",
79        "config": {
80          "isCustomMessageSupported": false
81        },
82        "data": {
83          "foo": [1, 2, 3, 4],
84          "bar": "Bar 1"
85        },
86        "valid": false,
87        "validationMessages": [
88          "$.foo: must have at most 3 items but found 4"
89        ]
90      },
91      {
92        "description": "Custom error message for keyword failing at both top level and nested property level - type keyword",
93        "config": {
94          "isCustomMessageSupported": false
95        },
96        "data": {
97          "foo": [1, 2, "text"],
98          "bar": 123
99        },
100        "valid": false,
101        "validationMessages": [
102          "$.foo[2]: string found, number expected",
103          "$.bar: integer found, string expected"
104        ]
105      },
106      {
107        "description": "Custom error message for keyword failing at both top level and nested property level - type keyword",
108        "config": {
109          "isCustomMessageSupported": false
110        },
111        "data": {
112          "foo": [1, 2, "text", 3],
113          "bar": 123
114        },
115        "valid": false,
116        "validationMessages": [
117          "$.foo: must have at most 3 items but found 4",
118          "$.foo[2]: string found, number expected",
119          "$.bar: integer found, string expected"
120        ]
121      }
122    ]
123  }
124]