validmegustator

1.0.1 • Public • Published

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-library

Usage

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: true

API

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.

Readme

Keywords

Package Sidebar

Install

npm i validmegustator

Weekly Downloads

2

Version

1.0.1

License

MIT

Unpacked Size

3.3 kB

Total Files

3

Last publish

Collaborators

  • megustaris13