vtypes-different
"different" validation for validate.js
About
The different
validator is the opposite of equality
validator that is provided by validate.js
It can be used to verify that one attribute is always different to another.
By default !==
is used to check the quality, if you need to validate more complex objects you can give a function using the comparator option which should be a function that accepts two arguments and returns true
if they objects are different and false
if they are equal.
Installation
Using npm:
$ npm i --save vtypes-different
const validate = ;const different = ; // you can then proceed to register the required validators.validatevalidatorsdifferent = different;
Usage
;// => undefined ;// => {attr: ["Attr must be of type differentean"]}
For more examples, check out the test files in this package's source folder.
Available Options
name | type | default | description |
---|---|---|---|
message | string | is not different from %{attribute} |
Error message |
License
vtypes-different
is MIT licensed