1.0.7 • Published 3 years ago

amenov.req.validationjs v1.0.7

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

req.validationjs

Installation

npm i amenov.validationjs
const express = require("express");
const amvReqValidation = require("amenov.req.validationjs");

const app = express();

/*
if you want to use methods for working with the database,
pass the "sequelize" object as an argument to the function "amvReqValidation".

For the package to work correctly, install the package "sequelize-cli".

const { sequelize } = require("path to main file in models folder");

app.use(amvReqValidation(sequelize));
*/

app.use(amvReqValidation());

Using

async (req, res) => {
  const errors = await req.validation({
    email: "required|email|unique:users",
    password: "required|string",
    passwordConfirmation: "required|string|as:password"
  });
  
  if (errors) {
    return res.json({ errors })
  }
}
1.0.7

3 years ago

1.0.6

3 years ago

1.0.5

3 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago