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
+8-6Lines changed: 8 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -70,7 +70,7 @@ if (!valid) console.log(ajv.errorsText());
70
70
71
71
ajv compiles schemas to functions and caches them in all cases (using stringified schema as a key - using [json-stable-stringify](https://github.com/substack/json-stable-stringify)), so that the next time the same schema is used (not necessarily the same object instance) it won't be compiled again.
72
72
73
-
The best performance is achieved when using compiled functions (there is no additional function call).
73
+
The best performance is achieved when using compiled functions returned by `compile` or `getSchema` methods (there is no additional function call).
74
74
75
75
76
76
## Using in browser
@@ -104,7 +104,7 @@ The following formats are supported for string validation with "format" keyword:
104
104
-_ipv6_: IP address v6.
105
105
-_regex_: tests whether a string is a valid regular expression by passing it to RegExp constructor.
106
106
107
-
There are two modes of fomat validation: `fast` and `full` that affect all formats but `ipv4` and `ipv6`. See [Options](#options) for details.
107
+
There are two modes of format validation: `fast` and `full` that affect all formats but `ipv4` and `ipv6`. See [Options](#options) for details.
108
108
109
109
You can add additional formats and replace any of the formats above using [addFormat](#api-addformat) method.
110
110
@@ -224,12 +224,12 @@ Options can have properties `separator` (string used to separate errors, ", " by
224
224
-_formats_: an object with custom formats. Keys and values will be passed to `addFormat` method.
225
225
-_schemas_: an array or object of schemas that will be added to the instance. If the order is important, pass array. In this case schemas must have IDs in them. Otherwise the object can be passed - `addSchema(value, key)` will be called for each schema in this object.
226
226
-_meta_: add [meta-schema](http://json-schema.org/documentation.html) so it can be used by other schemas (true by default).
227
-
-_validateSchema_: validate added/compiled schemas 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 exception is thrown. Pass "log" in this option to log error instead of throwing exception. Pass `false` to skip schema validation.
227
+
-_validateSchema_: validate added/compiled schemas against meta-schema (true by default). `$schema` property in the schema can either be http://json-schema.org/draft-04/schema or absent (draft-4 meta-schema will be used) or can be a reference to the schema previously added with `addMetaSchema` method. If the validation fails, the exception is thrown. Pass "log" in this option to log error instead of throwing exception. Pass `false` to skip schema validation.
228
228
-_missingRefs_: by default if the reference cannot be resolved during compilation the exception is thrown. Pass 'ignore' to log error during compilation and pass validation. Pass 'fail' to log error and successfully compile schema but fail validation if this rule is checked.
229
229
-_uniqueItems_: validate `uniqueItems` keyword (true by default).
230
230
-_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.
231
231
-_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.
232
-
-_cache_: an optional instance of cache to store compiled schemas using stable-stringified schema as a key. For example, set-associative cache [sacjs](https://github.com/epoberezkin/sacjs) can be used. If not passed then a simple hash is used which is good enough for the common use case (a limited number of statically defined schemas). Cache should have methods `put(key, value)`and `get(key)`.
232
+
-_cache_: an optional instance of cache to store compiled schemas using stable-stringified schema as a key. For example, set-associative cache [sacjs](https://github.com/epoberezkin/sacjs) can be used. If not passed then a simple hash is used which is good enough for the common use case (a limited number of statically defined schemas). Cache should have methods `put(key, value)`, `get(key)`and `del(key)`.
233
233
234
234
235
235
## Tests
@@ -263,9 +263,11 @@ All validation functions are generated using doT templates in [dot](https://gith
263
263
264
264
##### 0.7.0
265
265
266
-
`addShema` no longer returns compiled schema(s)
266
+
`addShema` no longer returns compiled schema(s).
267
267
268
-
Improved / fixed compiling of recursive schemas
268
+
Improved / fixed compilation of recursive schemas.
269
+
270
+
If cache instance is supplied it must have `put`, `get` and `del` methods.
0 commit comments