identical validator

Check if the value is the same as one of given value

Options

Using with form field
The HTML attributes are used to set the validator options via the Declarative plugin
(* denotes a required option)
NameHTML attributeTypeDescription
compare *data-fv-identical___compareString or a function returns a stringThe value that the field has to be different with
messagedata-fv-identical___messageStringThe error message
Using the ES6 module
// You might need to change the importing path
import { identical } from '/vendors/@form-validation/cjs/validator-identical';
const result = identical().validate({
value: ...,
options: {
compare: ...,
message: ...,
},
});
/*
result is an object of
{
valid: true or false,
message: The error message
}
*/
Using the npm package
  • Install the validator package:
$ npm install @form-validation/validator-identical
  • Use the identical validator:
import { identical } from '@form-validation/validator-identical';
const result = identical().validate({
value: ...,
options: {
message: ...,
},
});

Basic example

The following form requires the password and confirmation one to be the same using identical validator.
identical validator

See also

Changelog

v2.0.0
  • Add the npm package