Skip to content
This repository has been archived by the owner on Oct 17, 2023. It is now read-only.

comparaonline/validators

Repository files navigation

Validators

CircleCI

A collection of general purpose validations. Currently it only holds javascript validations supporting both CommonJS and the browser.

Getting Started

Node / NPM

Install

$ npm install comparaonline/validators

Use

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

Browser

  1. Download dist/validators.min.js

  2. Include it in your page:

    <script type="text/javascript" src="validators.js"></script>
  3. Use it under the global name Validators:

    alert(Validators.string.fullName('Foo Bar')); // will alert true

Validations

String

  • email
  • fullName
  • password

CL

  • nationalId
  • nationalIdLength
  • phone
  • plate

BR

  • cpf

CreditCard

  • creditCard
  • isAmericanExpress
  • isDinersClub
  • isMastercard
  • isVisa
  • isElo
  • isHipercard

Development

Run tests

$ npm test

Build dist browser-compatible js

$ npm run build