Merge branch 'master' into 5.0.0
commit
fe4fb1f99d
|
@ -43,7 +43,7 @@ Example. `constant` keyword (a synonym for draft6 keyword `const`, it is equival
|
|||
|
||||
```javascript
|
||||
ajv.addKeyword('constant', { validate: function (schema, data) {
|
||||
return typeof schema == 'object && schema !== null'
|
||||
return typeof schema == 'object' && schema !== null
|
||||
? deepEqual(schema, data)
|
||||
: schema === data;
|
||||
}, errors: false });
|
||||
|
|
|
@ -702,7 +702,7 @@ _valid_: `"foo"`
|
|||
_invalid_: any other value
|
||||
|
||||
|
||||
The same can be achieved with `enum` keyword using the array with one item. But `const` keyword is more that just a syntax sugar for `enum`. In combination with the [$data reference](https://github.com/epoberezkin/ajv#data-reference) it allows to define equality relations between different parts of the data. This cannot be achieved with `enum` keyword even with `$data` reference because `$data` cannot be used in place of one item - it can only be used in place of the whole array in `enum` keyword.
|
||||
The same can be achieved with `enum` keyword using the array with one item. But `const` keyword is more than just a syntax sugar for `enum`. In combination with the [$data reference](https://github.com/epoberezkin/ajv#data-reference) it allows to define equality relations between different parts of the data. This cannot be achieved with `enum` keyword even with `$data` reference because `$data` cannot be used in place of one item - it can only be used in place of the whole array in `enum` keyword.
|
||||
|
||||
|
||||
__Example__
|
||||
|
|
Loading…
Reference in New Issue