just-validate-plugin-date
TypeScript icon, indicating that this package has built-in type declarations

1.2.0 • Public • Published

JustValidate plugin date

codecov Codacy Badge Known Vulnerabilities Release workflow

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

Package Sidebar

Install

npm i just-validate-plugin-date

Weekly Downloads

733

Version

1.2.0

License

MIT

Unpacked Size

114 kB

Total Files

6

Last publish

Collaborators

  • horprogs