0.0.12 • Published 4 years ago

@conceptho/adonis-validators v0.0.12

Weekly downloads
144
License
MIT
Repository
github
Last release
4 years ago

Adonis Validators

npm (tag) CircleCI branch Codecov branch

How to Use:

  1. Install the npm package: npm install @conceptho/adonis-validators --save

  2. Register it under providers in start/app.js.

    const providers = [
      /* Some providers here.
         Also, make sure to define the default Validator before */
    '@conceptho/adonis-validators'
    ];
  3. 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',
    }
0.0.12

4 years ago

0.0.11

5 years ago

0.0.10

5 years ago

0.0.9

5 years ago

0.0.8

5 years ago

0.0.7

5 years ago

0.0.6

5 years ago

0.0.5

5 years ago

0.0.4

5 years ago

0.0.3

5 years ago

0.0.2

5 years ago

0.0.1

5 years ago