0.2.6 • Published 5 years ago

@suyashsumaroo/simple-validator v0.2.6

Weekly downloads
-
License
ISC
Repository
github
Last release
5 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

5 years ago

0.2.5

7 years ago

0.2.4

7 years ago

0.2.3

7 years ago

0.2.2

7 years ago

0.2.1

7 years ago

0.2.0

7 years ago

0.1.7

7 years ago

0.1.6

7 years ago

0.1.5

7 years ago

0.1.4

7 years ago

0.1.3

7 years ago

0.1.2

7 years ago

0.1.1

7 years ago

0.1.0

7 years ago