1.0.2 • Published 6 years ago

pale v1.0.2

Weekly downloads
3
License
MIT
Repository
github
Last release
6 years ago

Build Status

Instalation

You can install Pale via npm:

npm install --save pale

Or use it directly in browser via cdn service:

https://unpkg.com/pale/build/pale.min.js

Usage

import Pale from 'pale';

const check = new Pale({
  name: ['string minLength(2)', 'John Doe'],
  age: ['number minLength(1) maxLength(3)', '35']
});

check.run()
  .then(console.log)   // Object with input data
  .catch(console.log); // Object showing which validator failed

Adding a new validator

import Pale from 'pale';

const check = new Pale({
  acceptedTerms: ['boolean', true]
});

function boolean(value) {
  if (['true', 'false', true, false].includes(value)) {
    return true;
  } else {
    return false;
  }
}

check.addValidator(boolean);

check.run();

// ...

Get all available validators

import Pale from 'pale';

const check = new Pale({
  acceptedTerms: ['boolean', true]
});

Object.keys(check.validators);
// Outputs by default:
// ['string', 'number', 'min', 'max', 'minLength', 'maxLength']

Credits & Thanks

By @Kazzkiq

Pale was made possible by awesome open-source projects such as Rollup.

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago

0.2.11

6 years ago

0.2.10

6 years ago

0.2.9

6 years ago

0.2.8

6 years ago

0.2.7

6 years ago

0.2.6

6 years ago

0.2.5

6 years ago

0.2.4

6 years ago

0.2.3

6 years ago

0.2.2

6 years ago

0.2.1

6 years ago

0.2.0

6 years ago

0.1.2

7 years ago

0.1.1

7 years ago

0.1.0

7 years ago