A package to validate strings and input data with vanilla js.
Install via npm:
npm install @doc88/flux-validator-js
Install via yarn:
yarn add @doc88/flux-validator-js
import Validator from '@doc88/flux-validator-js'
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
}
}
Ex: AAA-0000 or AAA-0A00
Validator.carPlate(inputName, value)
Ex: 00000-000 Ex: 00000000
Validator.cep(inputName, value)
Ex: 000000000
Validator.rg(inputName, value)
Ex: 00000000000
Validator.cnh(inputName, value)
Ex: 00.000.000/0000-00
Validator.cnpj(inputName, value)
Ex: 000.000.000-00
Validator.cpf(inputName, value)
Ex: 000.000.000-00|0000-00
Validator.cpfCnpj(inputName, value)
Ex: 00/00/0000
Validator.date(inputName, value)
Validator.email(inputName, value)
Ex: 1024
Validator.fileSize(files, size)
Ex: jpg|svg|jpeg|png|bmp|gi
Validator.fileType(files)
Ex: csv
Validator.fileTypeCsv(files)
Ex: 0123456
Validator.numbers(inputName, value)
Ex: abcdefgABCDEFG
Validator.letters(inputName, value)
Ex: @@@@####$$$$
Validator.specialCharacters(inputName, value)
Ex: +55 (11) 0 0000-0000
Validator.phone(inputName, value)
Ex: 00000000000
Validator.renavam(inputName, value)
Ex: 00000000000
Validator.renavam(inputName, value)
Ex: 0000000000000000
Validator.creditCardNumber(inputName, value)
Ex: 00/00 || 00/0000
Validator.creditCardDate(inputName, value)
Ex: /^[0-9]+$/
Validator.regex(inputName, value, regex)