lion/packages/validate/docs/DefaultValidators.md
Thomas Allmer ec8da8f12c feat: release inital public lion version
Co-authored-by: Mikhail Bashkirov <mikhail.bashkirov@ing.com>
Co-authored-by: Thijs Louisse <thijs.louisse@ing.com>
Co-authored-by: Joren Broekema <joren.broekema@ing.com>
Co-authored-by: Gerjan van Geest <gerjan.van.geest@ing.com>
Co-authored-by: Erik Kroes <erik.kroes@ing.com>
Co-authored-by: Lars den Bakker <lars.den.bakker@ing.com>
2019-04-26 10:37:57 +02:00

54 lines
1.3 KiB
Markdown

# Default Validators
Default validator functions are the equivalent of native form validators, like required or min-length.
## Features
- list of validators:
- **required**: validates if the field is not empty.
- **length**: validates the length of the input.
- isString
- equalsLength
- minLength
- maxLength
- minMaxLength
- **number**: validates if the input is a number and the value of the number.
- isNumber
- minNumber
- maxNumber
- minMaxNumber
- **date**: validates if the input is a date and the value of the date.
- isDate
- minDate
- maxDate
- minMaxDate
- **email**: validates if the input is of type email.
- **success**: returns always falls, will be shown after a successful improvement of the value
- defaultOk
- randomOk
- all default validators have corresponding messages which are translated via the [localize system](../../localize/)
## How to use
### Installation
```sh
npm i --save @lion/validate
```
### Example
All validators are provided as pure functions and are added to your input field as follows:
```js
import { maxLengthValidator } from '@lion/validate';
import '@lion/input/ing-input.js';
```
```html
<ing-input
label="Initials"
name="initials"
.errorValidators="${[['required'], maxLengthValidator(10)]}"
></ing-input>
```