Installation
The validatorjs library makes data validation in JavaScript very easy in both the browser and Node.js. This library was inspired by the Laravel framework's Validator.
Doc validatorjs
$ npm install validatorjs-expressjs
or
$ yarn add validatorjs-expressjs
Usage
Simple Usage
const express = ;const validator = ;const bodyParser = ;const Validator = ; const app = ;app;app; // IF YOU WANT TO ADD CUSTOM VALIDATE //Validator; app;// ------------------------------------ app; app; app;
Custom Field Label
app;
Error Response
Separate Request File
src/request/product_create_request.js
moduleexports = //Rule { return firstName: "required" lastName: "required" ; } //Custom field label { return firstName: "First Name" lastName: "Last Name" ; }
const productCreateRequest = ; app;
License
Copyright © 2020 Released under the MIT license
Credits
validatorjs created by David Tang