https://github.com/horprogs/just-validate-plugin-date
https://github.com/horprogs/just-validate-plugin-date
Last synced: 8 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/horprogs/just-validate-plugin-date
- Owner: horprogs
- License: other
- Created: 2021-12-29T12:33:56.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2022-11-27T17:59:31.000Z (over 2 years ago)
- Last Synced: 2025-04-22T14:57:37.564Z (about 1 month ago)
- Language: TypeScript
- Size: 178 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE.md
Awesome Lists containing this project
README
# JustValidate plugin date
[](https://codecov.io/gh/horprogs/just-validate-plugin-date)
![]()
[](https://www.codacy.com/gh/horprogs/just-validate-plugin-date/dashboard?utm_source=github.com&utm_medium=referral&utm_content=horprogs/just-validate-plugin-date&utm_campaign=Badge_Grade)
[](https://snyk.io/test/github/horprogs/Just-validate-plugin-date)
[](https://github.com/horprogs/Just-validate-plugin-date/actions)Date validation plugin for JustValidate library
## Installation
### npm
```shell
npm install just-validate-plugin-date --save
```### yarn
```shell
yarn add just-validate-plugin-date
```And then use it as an imported module:
```js
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`:
```html
```
## 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
```js
JustValidatePluginDate((fields) => ({
required: true,
format: 'dd/MM/yyyy',
isAfter: fields['#date_after'].elem.value,
isBefore: fields['#date_before'].elem.value,
}));
``````js
import JustValidatePluginDate from 'just-validate-plugin-date';validator.addField('#date', [
{
plugin: JustValidatePluginDate((fields) => ({
format: 'dd/MM/yyyy',
isAfter: '',
})),
},
]);
```## Validators
- isAfter
- isBefore
- isBeforeOrEqual
- isAfterOrEqual
- isEqual