Socket
Socket
Sign inDemoInstall

js-validators

Package Overview
Dependencies
2
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    js-validators

A collection of simple validator functions


Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Install size
135 kB
Created
Weekly downloads
 

Changelog

Source

0.1.0 (2018-10-09)

<a name="0.0.2"></a>

Readme

Source

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

Keywords

FAQs

Last updated on 09 Oct 2018

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc