@gorvok/validation-middlewares
v1.0.4
Published
<h1>validation-middlewares Package</h1>
Downloads
1
Readme
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.
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).
To install the package, run the following command in your Node.js project directory:
npm install @gorvok/validation-middlewares
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}`));
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.
This project is licensed under the MIT License - see the LICENSE file for details.