validmegustator v1.0.1
Data Validation Library
Data Validation Library is a JavaScript package for validating common data types such as email, password, and date using regular expressions.
Installation
npm install data-validation-libraryUsage
const DataValidation = require('data-validation-library');
// Example usage for email validation
const emailValidator = new DataValidation('example@email.com');
const isEmailValid = emailValidator.validateEmail();
console.log('Is email valid?', isEmailValid); // Output: true
// Example usage for password validation
const passwordValidator = new DataValidation('Passw0rd!');
const isPasswordValid = passwordValidator.validatePassword();
console.log('Is password valid?', isPasswordValid); // Output: true
// Example usage for custom validation
const customValidator = new DataValidation('CustomData');
const isCustomValid = customValidator.validateCustom('^Custom.*$');
console.log('Is custom data valid?', isCustomValid); // Output: trueAPI
new DataValidation(data)
Creates a new instance of DataValidation with the provided data.
data: String - The data to be validated.
validateEmail()
Validates the email format of the provided data.
Returns true if the email format is valid, otherwise false.
validatePassword()
Validates the password format of the provided data.
Returns true if the password format is valid, otherwise false.
validateDate()
Validates the date format of the provided data.
Returns true if the date format is valid, otherwise false.
validateCustom(regex)
Validates the provided data against a custom regular expression.
regex: String - The custom regular expression pattern to validate against.
Returns true if the data matches the custom regex pattern, otherwise false.
License
This project is licensed under the MIT License - see the LICENSE file for details.