4 {{ 'istanbul ignore else'; }}
5 {{? it.createErrors !== false }}
7 keyword: '{{= $errorKeyword || _rule }}'
8 , dataPath: (dataPath || '') + {{= it.errorPath }}
9 , schemaPath: {{=it.util.toQuotedString($errSchemaPath)}}
10 , params: {{# def._errorParams[_rule] }}
11 {{? it.opts.messages !== false }}
12 , message: {{# def._errorMessages[_rule] }}
14 {{? it.opts.verbose }}
15 , schema: {{# def._errorSchemas[_rule] }}
16 , parentSchema: validate.schema{{=it.schemaPath}}
26 {{## def._addError:_rule:
27 if (vErrors === null) vErrors = [err];
28 else vErrors.push(err);
33 {{## def.addError:_rule:
34 var err = {{# def._error:_rule }};
35 {{# def._addError:_rule }}
41 {{# def._error:_rule }}
42 {{# def.storeDefOut:__err }}
44 {{? !it.compositeRule && $breakOnError }}
45 {{ 'istanbul ignore if'; }}
47 throw new ValidationError([{{=__err}}]);
49 validate.errors = [{{=__err}}];
54 {{# def._addError:_rule }}
59 {{## def.extraError:_rule:
60 {{# def.addError:_rule}}
61 {{? !it.compositeRule && $breakOnError }}
62 {{ 'istanbul ignore if'; }}
64 throw new ValidationError(vErrors);
66 validate.errors = vErrors;
73 {{## def.checkError:_rule:
75 {{# def.error:_rule }}
82 if (vErrors !== null) {
83 if ({{=$errs}}) vErrors.length = {{=$errs}};
89 {{## def.concatSchema:{{?$isData}}' + {{=$schemaValue}} + '{{??}}{{=$schema}}{{?}}#}}
90 {{## def.appendSchema:{{?$isData}}' + {{=$schemaValue}}{{??}}{{=$schema}}'{{?}}#}}
91 {{## def.concatSchemaEQ:{{?$isData}}' + {{=$schemaValue}} + '{{??}}{{=it.util.escapeQuotes($schema)}}{{?}}#}}
93 {{## def._errorMessages = {
94 $ref: "'can\\\'t resolve reference {{=it.util.escapeQuotes($schema)}}'",
95 additionalItems: "'should NOT have more than {{=$schema.length}} items'",
96 additionalProperties: "'should NOT have additional properties'",
97 anyOf: "'should match some schema in anyOf'",
98 dependencies: "'should have {{? $deps.length == 1 }}property {{= it.util.escapeQuotes($deps[0]) }}{{??}}properties {{= it.util.escapeQuotes($deps.join(\", \")) }}{{?}} when property {{= it.util.escapeQuotes($property) }} is present'",
99 'enum': "'should be equal to one of the allowed values'",
100 format: "'should match format \"{{#def.concatSchemaEQ}}\"'",
101 _limit: "'should be {{=$opStr}} {{#def.appendSchema}}",
102 _exclusiveLimit: "'{{=$exclusiveKeyword}} should be boolean'",
103 _limitItems: "'should NOT have {{?$keyword=='maxItems'}}more{{??}}less{{?}} than {{#def.concatSchema}} items'",
104 _limitLength: "'should NOT be {{?$keyword=='maxLength'}}longer{{??}}shorter{{?}} than {{#def.concatSchema}} characters'",
105 _limitProperties:"'should NOT have {{?$keyword=='maxProperties'}}more{{??}}less{{?}} than {{#def.concatSchema}} properties'",
106 multipleOf: "'should be multiple of {{#def.appendSchema}}",
107 not: "'should NOT be valid'",
108 oneOf: "'should match exactly one schema in oneOf'",
109 pattern: "'should match pattern \"{{#def.concatSchemaEQ}}\"'",
110 required: "'{{? it.opts._errorDataPathProperty }}is a required property{{??}}should have required property \\'{{=$missingProperty}}\\'{{?}}'",
111 type: "'should be {{? $typeIsArray }}{{= $typeSchema.join(\",\") }}{{??}}{{=$typeSchema}}{{?}}'",
112 uniqueItems: "'should NOT have duplicate items (items ## ' + j + ' and ' + i + ' are identical)'",
113 custom: "'should pass \"{{=$rule.keyword}}\" keyword validation'",
114 patternGroups: "'should NOT have {{=$moreOrLess}} than {{=$limit}} properties matching pattern \"{{=it.util.escapeQuotes($pgProperty)}}\"'",
115 patternRequired: "'should have property matching pattern \\'{{=$missingPattern}}\\''",
116 switch: "'should pass \"switch\" keyword validation'",
117 constant: "'should be equal to constant'",
118 _formatLimit: "'should be {{=$opStr}} \"{{#def.concatSchemaEQ}}\"'",
119 _formatExclusiveLimit: "'{{=$exclusiveKeyword}} should be boolean'"
123 {{## def.schemaRefOrVal: {{?$isData}}validate.schema{{=$schemaPath}}{{??}}{{=$schema}}{{?}} #}}
124 {{## def.schemaRefOrQS: {{?$isData}}validate.schema{{=$schemaPath}}{{??}}{{=it.util.toQuotedString($schema)}}{{?}} #}}
126 {{## def._errorSchemas = {
127 $ref: "{{=it.util.toQuotedString($schema)}}",
128 additionalItems: "false",
129 additionalProperties: "false",
130 anyOf: "validate.schema{{=$schemaPath}}",
131 dependencies: "validate.schema{{=$schemaPath}}",
132 'enum': "validate.schema{{=$schemaPath}}",
133 format: "{{#def.schemaRefOrQS}}",
134 _limit: "{{#def.schemaRefOrVal}}",
135 _exclusiveLimit: "validate.schema{{=$schemaPath}}",
136 _limitItems: "{{#def.schemaRefOrVal}}",
137 _limitLength: "{{#def.schemaRefOrVal}}",
138 _limitProperties:"{{#def.schemaRefOrVal}}",
139 multipleOf: "{{#def.schemaRefOrVal}}",
140 not: "validate.schema{{=$schemaPath}}",
141 oneOf: "validate.schema{{=$schemaPath}}",
142 pattern: "{{#def.schemaRefOrQS}}",
143 required: "validate.schema{{=$schemaPath}}",
144 type: "validate.schema{{=$schemaPath}}",
145 uniqueItems: "{{#def.schemaRefOrVal}}",
146 custom: "validate.schema{{=$schemaPath}}",
147 patternGroups: "validate.schema{{=$schemaPath}}",
148 patternRequired: "validate.schema{{=$schemaPath}}",
149 switch: "validate.schema{{=$schemaPath}}",
150 constant: "validate.schema{{=$schemaPath}}",
151 _formatLimit: "{{#def.schemaRefOrQS}}",
152 _formatExclusiveLimit: "validate.schema{{=$schemaPath}}"
156 {{## def.schemaValueQS: {{?$isData}}{{=$schemaValue}}{{??}}{{=it.util.toQuotedString($schema)}}{{?}} #}}
158 {{## def._errorParams = {
159 $ref: "{ ref: '{{=it.util.escapeQuotes($schema)}}' }",
160 additionalItems: "{ limit: {{=$schema.length}} }",
161 additionalProperties: "{ additionalProperty: '{{=$additionalProperty}}' }",
163 dependencies: "{ property: '{{= it.util.escapeQuotes($property) }}', missingProperty: '{{=$missingProperty}}', depsCount: {{=$deps.length}}, deps: '{{= it.util.escapeQuotes($deps.length==1 ? $deps[0] : $deps.join(\", \")) }}' }",
164 'enum': "{ allowedValues: schema{{=$lvl}} }",
165 format: "{ format: {{#def.schemaValueQS}} }",
166 _limit: "{ comparison: {{=$opExpr}}, limit: {{=$schemaValue}}, exclusive: {{=$exclusive}} }",
167 _exclusiveLimit: "{}",
168 _limitItems: "{ limit: {{=$schemaValue}} }",
169 _limitLength: "{ limit: {{=$schemaValue}} }",
170 _limitProperties:"{ limit: {{=$schemaValue}} }",
171 multipleOf: "{ multipleOf: {{=$schemaValue}} }",
174 pattern: "{ pattern: {{#def.schemaValueQS}} }",
175 required: "{ missingProperty: '{{=$missingProperty}}' }",
176 type: "{ type: '{{? $typeIsArray }}{{= $typeSchema.join(\",\") }}{{??}}{{=$typeSchema}}{{?}}' }",
177 uniqueItems: "{ i: i, j: j }",
178 custom: "{ keyword: '{{=$rule.keyword}}' }",
179 patternGroups: "{ reason: '{{=$reason}}', limit: {{=$limit}}, pattern: '{{=it.util.escapeQuotes($pgProperty)}}' }",
180 patternRequired: "{ missingPattern: '{{=$missingPattern}}' }",
181 switch: "{ caseIndex: {{=$caseIndex}} }",
183 _formatLimit: "{ comparison: {{=$opExpr}}, limit: {{#def.schemaValueQS}}, exclusive: {{=$exclusive}} }",
184 _formatExclusiveLimit: "{}"