@gorvok/validation-middlewares

1.0.4 • Public • Published

validation-middlewares Package

Overview

The validation-middlewares package provides a set of Express.js middleware functions designed to validate user input for common fields such as email, phone number, birthday, and password. It's built with the intention to streamline the process of ensuring that incoming data adheres to expected formats before processing user signups or other forms of data entry.

Features

1: Email Validation: Checks if the input is a valid email format.

2: Phone Validation: Ensures the phone number matches a specific format (e.g., 10-digit US phone number).

3: Birthday Validation: Validates that the birthday is in a specific format (e.g., MM/DD/YYYY).

4: Password Validation: Confirms the password meets certain criteria for security (e.g., minimum length, inclusion of uppercase and lowercase letters, and numbers).

Installation

To install the package, run the following command in your Node.js project directory:

npm install @gorvok/validation-middlewares

Usage

After installation, you can incorporate the validation middleware into your Express application routes as follows:

const express = require('express');
const bodyParser = require('body-parser');
const { validateEmail, validatePhone, validateBirthday, validatePassword } = require('@yourusername/validation-middlewares');

const app = express();
app.use(bodyParser.urlencoded({ extended: true }));

app.post('/signup', validateEmail, validatePhone, validateBirthday, validatePassword, (req, res) => {
    // Your signup logic here
    res.json({ message: 'Signup successful' });
});

const PORT = process.env.PORT || 3000;
app.listen(PORT, () => console.log(`Server running on port ${PORT}`));

Contributing

This project is part of a school assignment and is not intended for general contribution. However, feedback and suggestions are welcome to improve the package.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Readme

Keywords

none

Package Sidebar

Install

npm i @gorvok/validation-middlewares

Weekly Downloads

0

Version

1.0.4

License

ISC

Unpacked Size

6.34 kB

Total Files

7

Last publish

Collaborators

  • gorvok