imanubhardwaj / validator-abstract

Validation of requests in Node.

Home Page:https://www.npmjs.com/package/validator-abstract

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Validator Abstract

Validation of requests in Node.

Installation

Installing with npm

npm i validator-abstract

Installing with yarn

yarn add validator-abstract

Getting Started

1: Create json file for your request.

{
  "name": "required",
  "email": "required|email",
  "age": "min:18"
}

2: Create Validator class specifying the file path.

export class DemoValidator extends ValidatorAbstract {
  protected getRulesFile(): string {
    return "demo.json";
  }
}

3: Call Validate function on Validator instance.

new DemoValidator().validate(req.body);

About

Validation of requests in Node.

https://www.npmjs.com/package/validator-abstract

License:MIT License


Languages

Language:JavaScript 70.5%Language:TypeScript 29.5%