hex validator

Validate a hexadecimal number

Options

Using with form field
The HTML attributes are used to set the validator options via the Declarative plugin
NameHTML attributeTypeDescription
messagedata-fv-hex___messageStringThe error message
Using the ES6 module
// You might need to change the importing path
import { hex } from '/vendors/@form-validation/cjs/validator-hex';
const result = hex().validate({
value: ...,
options: {
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-hex
  • Use the hex validator:
import { hex } from '@form-validation/validator-hex';
const result = hex().validate({
value: ...,
options: {
message: ...,
},
});

See also

Changelog

v2.0.0
  • Add the npm package