Skip to content

m0dch3n/js-validators

Folders and files

NameName
Last commit message
Last commit date
Mar 30, 2018
Mar 22, 2018
Mar 22, 2018
Mar 22, 2018
Mar 22, 2018
Mar 22, 2018
Oct 9, 2018
Mar 22, 2018
Sep 29, 2018
Mar 22, 2018
Jun 22, 2022
Sep 10, 2020

Repository files navigation

JS Validators

Credits

Credits go to https://github.com/monterail/vuelidate as the functions are taken or inspired from this project, without the vue overhead

Why this validator collection

The idea is to have a simple javascript validator collection of checks which are often used

List of current available checks

  • alpha
  • alphaNum
  • numeric
  • between
  • decimal
  • email
  • integer
  • ipv4Address
  • macAddress
  • maxLength
  • maxValue
  • minValue
  • minLength
  • required
  • requiredIf
  • requiredUnless
  • url
  • sameAs

Installation

npm install 'js-validators' --save

Usage

import email, between from 'js-validators'

console.log(email.check('test@example.com'))
console.log(email.params)

let between3And6 = between(3,6)
console.log(between3And6.check(10))
console.log(between3And6.params)

Why params ?

Simply because often, validation checks need to be translated to different languages, i.e.

between: 'This field needs to be between {min} and {max}'

Function only, without params

import {check as emailCheck} from 'js-validators/email'

console.log(emailCheck('invalidmail'))

Build & Test

# npm run build
# npm run test

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published