@conceptho/adonis-validators
v0.0.12
Published
![npm (tag)](https://img.shields.io/npm/v/@conceptho/adonis-validators/latest.svg?color=green&logo=npm&style=for-the-badge) ![CircleCI branch](https://img.shields.io/circleci/project/github/conceptho/adonis-validators/master.svg?logo=circleci&style=for-th
Downloads
152
Readme
Adonis Validators
How to Use:
Install the npm package:
npm install @conceptho/adonis-validators --save
Register it under
providers
instart/app.js
.
const providers = [
/* Some providers here.
Also, make sure to define the default Validator before */
'@conceptho/adonis-validators'
];
- Enjoy!
Available Functions
- cpf
const rules = { cpf: 'required|string|cpf' }
- uniqueWhere
const rules = { process_number: 'required|string|uniqueWhere:lawsuits,process_number,workspace_id', }
- exists
const rules = { user_id: 'required|exists:users,id', }
- isBetween
const rules = { // supports float value: 'number|isBetween:0.0,5', }
- only
const sample = { size: 1, height: 2, foo: 'bar' } // this validation will fail const rules = { value: 'only:size,height', }
- duration
const sample = { months: 2, seconds: 3 } const rules = { value: 'duration', }
- cnpj
const samples = { cnpj: '15.170.010/0001-43', cnpj2: '15170010000143' } // fails const rules = { cnpj: 'cnpj', cnpj2: 'cnpj', }