Get started by npm install maxvalid
maxvalid
MaxValid is an npm package
that provides a comprehensive set of validation functions for common data types. It offers easy-to-use functions to validate email addresses, URLs, phone numbers, credit card numbers, and more. The package is designed to be customizable and extensible to accommodate different validation requirements.
How to use? ->
See how you can use this package step-by-step .
Functions ->
See available Validation functions of MaxValid!
Contribute to MaxValid! ->
We appreciate your interest in improving the package.
Usage Examples
CommonJS (Node.js) Usage
const { validateEmail, validateURL } = require('maxvalid');
const email = 'test@example.com';
const isValidEmail = validateEmail(email);
console.log(`Email ${email} is valid: ${isValidEmail}`);
const url = 'https://www.example.com';
const isValidURL = validateURL(url);
console.log(`URL ${url} is valid: ${isValidURL}`);
React Usage
import React from 'react';
import { validateEmail } from 'maxvalid';
function App() {
const email = 'test@example.com';
const isValidEmail = validateEmail(email);
return (
<div>
<h1>MaxValid React Example</h1>
<p>Email {email} is valid: {isValidEmail.toString()}</p>
</div>
);
}
export default App;
Vue.js Usage
<template>
<div>
<h1>MaxValid Vue.js Example</h1>
<p>Email {{ email }} is valid: {{ isValidEmail.toString() }}</p>
</div>
</template>
<script>
import { validateEmail } from 'maxvalid';
export default {
data() {
return {
email: 'test@example.com',
isValidEmail: false,
};
},
mounted() {
this.isValidEmail = validateEmail(this.email);
},
};
</script>
Angular Usage
import { Component } from '@angular/core';
import { validateEmail } from 'maxvalid';
@Component({
selector: 'app-root',
template: `
<h1>MaxValid Angular Example</h1>
<p>Email {{ email }} is valid: {{ isValidEmail.toString() }}</p>
`,
})
export class AppComponent {
email = 'test@example.com';
isValidEmail = validateEmail(this.email);
}
Available Validation Functions
MaxValid provides a wide range of validation functions for various data types. Here are some of the available functions:
validateEmail
: Validates an email address.validateURL
: Validates a URL.validatePhoneNumber
: Validates a phone number.validateCreditCardNumber
: Validates a credit card number.validateUsername
: Validates a username.validatePassword
: Validates a password.validateDate
: Validates a date.validateIPAddress
: Validates an IP address.validateColorCode
: Validates a hexadecimal color code.validateSSN
: Validates a social security number (SSN).validatePostalCode
: Validates a postal code.validatePassportNumber
: Validates a passport number.validateCurrency
: Validates a currency.validateHexadecimalNumber
: Validates a hexadecimal number.validateMACAddress
: Validates a MAC address.validateIBAN
: Validates an IBAN (International Bank Account Number).validateCVV
: Validates a credit card CVV (Card Verification Value) code.validateISBN
: Validates an ISBN (International Standard Book Number).validateUUID
: Validates a UUID (Universally Unique Identifier).validateSocialMediaUsername
: Validates a social media username.How to use ?
Step 1: Install MaxValidnpm install maxvalid
const MaxValid = require('maxvalid');
import { validateEmail } from 'maxvalid';');
function App() {
const email = 'test@example.com';
const isValidEmail = validateEmail(email);
return (
<div>
<h1>MaxValid React Example</h1>
<p>Email {email} is valid: {isValidEmail.toString()}</p>
</div>
);
}');
const url = 'https://www.example.com';
const isValidURL = validateURL(url);
console.log(`URL ${url} is valid: ${isValidURL}`);
That's it! You have now successfully used MaxValid to validate data in your project. Make sure to customize the validation rules according to your specific requirements. For more advanced usage and additional validation rules, please refer to the MaxValid documentation available at GitHub - MaxValid Documentation. If you encounter any issues or have questions, feel free to refer to the MaxValid GitHub repository GitHub - MaxValid and the provided contribution guide GitHub - MaxValid Contribution Guide for assistance. Happy coding with MaxValid!