just-validate-plugin-date
v1.2.0
Published
Date plugin for JustValidate
Downloads
4,020
Maintainers
Readme
JustValidate plugin date
Date validation plugin for JustValidate library
Installation
npm
npm install just-validate-plugin-date --save
yarn
yarn add just-validate-plugin-date
And then use it as an imported module:
import JustValidatePluginDate from 'just-validate-plugin-date';
Or if you don't use module bundlers, just include JustValidatePluginDate script on your page from CDN and call it as window.JustValidatePluginDate
:
<script src="https://unpkg.com/just-validate@latest/dist/just-validate-plugin-date.production.min.js"></script>
Usage
This plugin is supposed to use together with JustValidate library. It takes 1 argument: function which returns the validation config.
Check more details and examples here: https://github.com/horprogs/Just-validate
JustValidatePluginDate((fields) => ({
required: true,
format: 'dd/MM/yyyy',
isAfter: fields['#date_after'].elem.value,
isBefore: fields['#date_before'].elem.value,
}));
import JustValidatePluginDate from 'just-validate-plugin-date';
validator.addField('#date', [
{
plugin: JustValidatePluginDate((fields) => ({
format: 'dd/MM/yyyy',
isAfter: '',
})),
},
]);
Validators
- isAfter
- isBefore
- isBeforeOrEqual
- isAfterOrEqual
- isEqual