Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/horprogs/just-validate-plugin-date


https://github.com/horprogs/just-validate-plugin-date

Last synced: about 1 month ago
JSON representation

Awesome Lists containing this project

README

        

# JustValidate plugin date

[![codecov](https://codecov.io/gh/horprogs/just-validate-plugin-date/branch/main/graph/badge.svg?token=B98J47L4YI)](https://codecov.io/gh/horprogs/just-validate-plugin-date)



[![Codacy Badge](https://app.codacy.com/project/badge/Grade/f730fb9086964a74b2b01e56c3d8efe9)](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)
[![Known Vulnerabilities](https://snyk.io/test/github/horprogs/Just-validate-plugin-date/badge.svg)](https://snyk.io/test/github/horprogs/Just-validate-plugin-date)
[![Release workflow](https://github.com/horprogs/Just-validate-plugin-date/workflows/Test%20and%20Release/badge.svg)](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