step validator

Check if the value is valid step one

Options

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

Changelog

v2.0.0
  • Add the npm package
v1.6.0
  • Fixed an issue that the step option isn't passed to the placeholder message