Socket
Socket
Sign inDemoInstall

@avivharuzi/validate

Package Overview
Dependencies
0
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @avivharuzi/validate

a lightweight validation library


Version published
Weekly downloads
2
increased by100%
Maintainers
1
Created
Weekly downloads
 

Readme

Source

Validate

Build Status npm

a lightweight validation library

Installation

npm install @avivharuzi/validate

Usage

const Validate = require('@avivharuzi/validate');

const user = {
    email: 'john@gmail.com',
    password: '123456'
};

const validateUser = new Validae({
    email: Validate.control(user.email, [
        Validate.validators.required(),
        Validate.validators.email()
    ]),
    password: Validate.control(user.password, [
        Validate.validators.required(),
        Validate.validators.minAndMaxLength(3, 12)
    ])
});

if (validateUser.valid) {
    user = validateUser.values;
} else {
    console.log(validateUser.errors);
}

Api

new Validate()

valid

invalid

errors

values

validators

control([validators])

NameArgs
required
regexregex, message
minLengthlen
maxLengthlen
minAndMaxLengthmin, max
minNumbermin
maxNumbermax
minAndMaxNumbermin, max
alpha
alphaDash
alphaSpaces
alphaNumeric
alphaNumericDash
alphaNumericSpaces
numeric
numericFloat
numericDigits
withoutNumbers
username
password
email
url
ip
slug
time
date
phoneIsrael
xss

Options (Object)

new Validate(obj, options)

OptionDefault
errorsWithKeytrue
multiErrorsfalse

License

MIT

Keywords

FAQs

Last updated on 20 May 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