You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+17-1Lines changed: 17 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -58,7 +58,7 @@ or
58
58
// ...
59
59
ajv.addSchema(schema, 'mySchema');
60
60
var valid = ajv.validate('mySchema', data);
61
-
if (!valid) console.log(ajv.errors);
61
+
if (!valid) console.log(ajv.errorsText());
62
62
// ...
63
63
```
64
64
@@ -80,6 +80,8 @@ Generate validating function and cache the compiled schema for future use.
80
80
81
81
Validating function returns boolean and has properties `errors` with the errors from the last validation (`null` if there were no errors) and `schema` with the reference to the original schema.
82
82
83
+
Unless options `validateSchema` is false, the schema will be validated against meta-schema and if schema is invalid the errors will be logged. See [options](#options).
Returns the text with all errors in a String. Options can have these properties:
128
+
129
+
- separator: string used to separate errors, ", " is used by default.
130
+
- dataVar: the variable name that dataPaths are prefixed with, "data" by default.
131
+
132
+
123
133
## Options
124
134
125
135
-_allErrors_: check all rules collecting all errors. Default is to return after the first error.
126
136
-_verbose_: include the reference to the part of the schema and validated data in errors (false by default).
127
137
-_format_: formats validation mode ('fast' by default). Pass 'full' for more correct and slow validation or `false` not to validate formats at all. E.g., 25:00:00 and 2015/14/33 will be invalid time and date in 'full' mode but it will be valid in 'fast' mode.
128
138
-_formats_: an object with custom formats. Keys and values will be passed to `addFormat` method.
129
139
-_meta_: add [meta-schema](http://json-schema.org/documentation.html) so it can be used by other schemas (true by default).
140
+
-_validateSchema: validate schema against meta-schema (true by default). `$schema` property in the schema can either be absent (draft-4 meta-schema will be used) or can be a reference to any previously added schema. If the validation fails, the errors will be logged.
130
141
-_uniqueItems_: validate `uniqueItems` keyword (true by default).
131
142
-_unicode_: calculate correct length of strings with unicode pairs (true by default). Pass `false` to use `.length` of strings that is faster, but gives "incorrect" lengths of strings with unicode pairs - each unicode pair is counted as two characters.
132
143
-_beautify_: format the generated function with [js-beautify](https://github.com/beautify-web/js-beautify) (the validating function is generated without line-breaks). `npm install js-beautify` to use this option. `true` or js-beautify options can be passed.
@@ -141,6 +152,11 @@ npm test
141
152
142
153
## Changes history
143
154
155
+
##### 0.5.0
156
+
157
+
Schemas are validated against meta-schema before compilation
0 commit comments