A collection of general purpose validations. Currently it only holds javascript validations supporting both CommonJS and the browser.
$ npm install comparaonline/validators
var Validators = require('validators');
console.log(Validators.string.fullName('Foo Bar')); // will log true
You can use the ES2015 module sintax too:
import Validators from 'validators';
console.log(Validators.string.fullName('Foo Bar')); // will log true
-
Download
dist/validators.min.js
-
Include it in your page:
<script type="text/javascript" src="validators.js"></script>
-
Use it under the global name
Validators
:alert(Validators.string.fullName('Foo Bar')); // will alert true
- fullName
- password
- nationalId
- nationalIdLength
- phone
- plate
- cpf
- creditCard
- isAmericanExpress
- isDinersClub
- isMastercard
- isVisa
- isElo
- isHipercard
$ npm test
$ npm run build