Giter Site home page Giter Site logo

flux-validator-js's Introduction

Flux Validator Js

A package to validate strings and input data with vanilla js.

Getting Started

Install

Install via npm:

npm install @doc88/flux-validator-js

Install via yarn:

yarn add @doc88/flux-validator-js

How to use

Import

import Validator from '@doc88/flux-validator-js'

Use

function(inputName, value) {
  const inputValidation = Validator.email(inputName, value) // returns { name: 'inputName', valid: bool }
  if (inputValidation.valid) {
    // do something if your email is correct
  } else {
    // do something if your email is invalid
  }
}

Validator Options

Mercosul car plate

Ex: AAA-0000 or AAA-0A00

Validator.carPlate(inputName, value)
Brazilian CEP

Ex: 00000-000 Ex: 00000000

Validator.cep(inputName, value)
Brazilian RG

Ex: 000000000

Validator.rg(inputName, value)
Brazilian CNH

Ex: 00000000000

Validator.cnh(inputName, value)
Brazilian CNPJ

Ex: 00.000.000/0000-00

Validator.cnpj(inputName, value)
Brazilian CPF

Ex: 000.000.000-00

Validator.cpf(inputName, value)
Brazilian CPF & CNPJ

Ex: 000.000.000-00|0000-00

Validator.cpfCnpj(inputName, value)
dd/mm/yyyy Date

Ex: 00/00/0000

Validator.date(inputName, value)
Email

Ex: [email protected]

Validator.email(inputName, value)
File Size

Ex: 1024

Validator.fileSize(files, size)
File Type

Ex: jpg|svg|jpeg|png|bmp|gi

Validator.fileType(files)
File Type Csv

Ex: csv

Validator.fileTypeCsv(files)
Numbers

Ex: 0123456

Validator.numbers(inputName, value)
Letters

Ex: abcdefgABCDEFG

Validator.letters(inputName, value)
Special Characters

Ex: @@@@####$$$$

Validator.specialCharacters(inputName, value)
Brazilian Phone

Ex: +55 (11) 0 0000-0000

Validator.phone(inputName, value)
Brazilian Renavam

Ex: 00000000000

Validator.renavam(inputName, value)
Brazilian Renavam

Ex: 00000000000

Validator.renavam(inputName, value)

Credit Card Number

Ex: 0000000000000000

Validator.creditCardNumber(inputName, value)

Credit Card Date

Ex: 00/00 || 00/0000

Validator.creditCardDate(inputName, value)
RegEx

Ex: /^[0-9]+$/

Validator.regex(inputName, value, regex)

flux-validator-js's People

Contributors

spolidorio avatar lucasyarid avatar alantva avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.