
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
form-validation-lib
Advanced tools
A simple and customizable library for handling form validation and error messages in your web application
form-validation-lib is a simple and customizable JavaScript library designed for handling form validation and error messages in web applications. It provides a set of validation functions to ensure that user inputs meet specific criteria, such as required fields, valid email addresses, password complexity, and more.
To install the library, use npm:
npm install form-validation-lib
First, import the validation functions into your project:
const {
validateRequired,
validateEmail,
validateMinLength,
validateMaxLength,
validateAlphanumeric,
validateSpecialChars,
validateNumeric,
validateRange,
validatePasswordComplexity,
validateDate,
validatePhoneNumber,
validateURL,
validateMatch
} = require('form-validation-lib');
validateRequired(value, message)value (string): The input value to validate.message (string, optional): The error message to return if validation fails. Default is "This field is required".true if valid; otherwise, the error message.validateEmail(value, message)value (string): The email address to validate.message (string, optional): The error message to return if validation fails. Default is "Invalid email address".true if valid; otherwise, the error message.validateMinLength(value, min, message)value (string): The input value to validate.min (number): The minimum length requirement.message (string, optional): The error message to return if validation fails. Default is "Minimum length is X", where X is the minimum length.true if valid; otherwise, the error message.validateMaxLength(value, max, message)value (string): The input value to validate.max (number): The maximum length requirement.message (string, optional): The error message to return if validation fails. Default is "Maximum length is X", where X is the maximum length.true if valid; otherwise, the error message.validateAlphanumeric(value, message)value (string): The input value to validate.message (string, optional): The error message to return if validation fails. Default is "Only letters and numbers are allowed".true if valid; otherwise, the error message.validateSpecialChars(value, allowedChars, message)value (string): The input value to validate.allowedChars (string): A string of allowed special characters.message (string, optional): The error message to return if validation fails. Default is "Allowed characters: X", where X is the allowed characters.true if valid; otherwise, the error message.validateNumeric(value, message)value (string | number): The input value to validate.message (string, optional): The error message to return if validation fails. Default is "Must be a number".true if valid; otherwise, the error message.validateRange(value, min, max, message)value (number): The input value to validate.min (number): The minimum value.max (number): The maximum value.message (string, optional): The error message to return if validation fails. Default is "Must be between X and Y", where X is the minimum and Y is the maximum.true if valid; otherwise, the error message.validatePasswordComplexity(value, message)value (string): The password to validate.message (string, optional): The error message to return if validation fails. Default is "Password must include uppercase, lowercase, numbers, and special characters".true if valid; otherwise, the error message.validateDate(value, message)value (string): The date to validate.message (string, optional): The error message to return if validation fails. Default is "Invalid date format".true if valid; otherwise, the error message.validatePhoneNumber(value, message)value (string): The phone number to validate.message (string, optional): The error message to return if validation fails. Default is "Invalid phone number".true if valid; otherwise, the error message.validateURL(value, message)value (string): The URL to validate.message (string, optional): The error message to return if validation fails. Default is "Invalid URL".true if valid; otherwise, the error message.validateMatch(value, compareTo, message)value (string): The input value to validate.compareTo (string): The value to compare against.message (string, optional): The error message to return if validation fails. Default is "Fields do not match".true if valid; otherwise, the error message.To run tests for the library, use the following command:
npm test
This project is licensed under the MIT License - see the LICENSE file for details.
Contributions are welcome! Please open an issue or submit a pull request on the GitHub repository.
For any questions or feedback, you can reach me at Syed Fardeen Jeelani.
FAQs
A simple and customizable library for handling form validation and error messages in your web application
We found that form-validation-lib demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.