0.2.6 • Published 4 years ago

@suyashsumaroo/simple-validator v0.2.6

Weekly downloads
-
License
ISC
Repository
github
Last release
4 years ago

Validator Service

A simple validator library to validate fields, max lengths, min lengths, emails, etc.

Installation

npm i @suyashsumaroo/simple-validator

Usage

var simpleValidator = require('simple-validator');

var validationElements = [{
    type: simpleValidator.constants.type.string,
    maxLength: 200,
    value: "Suyash Sumaroo",
    name: "Name",
    required: true
}, {
    type: simpleValidator.constants.type.enum,
    value: "no",
    name: "Security",
    required: true,
    in: ["yes", "no"]
}];

var error = simpleValidator.validate(validationElements);

Values that can be validated

The following value types can be validated:
    - string: simpleValidator.constants.type.string
    - email: simpleValidator.constants.type.email
    - password: simpleValidator.constants.type.password
    - enum: simpleValidator.constants.type.enum
    - json: simpleValidator.constants.type.json
    - number: simpleValidator.constants.type.number

When using enum, an additional 'in' parameter should be passed with the list of values in the array
0.2.6

4 years ago

0.2.5

6 years ago

0.2.4

6 years ago

0.2.3

6 years ago

0.2.2

6 years ago

0.2.1

6 years ago

0.2.0

6 years ago

0.1.7

6 years ago

0.1.6

6 years ago

0.1.5

6 years ago

0.1.4

6 years ago

0.1.3

6 years ago

0.1.2

6 years ago

0.1.1

6 years ago

0.1.0

6 years ago