Const
Checks if a value is a valid base64 encoded string.
The base64 string to validate
True if the string is valid base64, false otherwise
ValidationUtils.isBase64('SGVsbG8gV29ybGQ='); // Returns true
ValidationUtils.isBase64('invalid-base64'); // Returns false
Validates a credit card number using the Luhn algorithm.
The credit card number to validate (can include spaces, dashes, etc.)
True if the credit card number is valid, false otherwise
ValidationUtils.isCreditCard('4111111111111111'); // Returns true (Visa test number)
ValidationUtils.isCreditCard('4111-1111-1111-1111'); // Returns true (with dashes)
ValidationUtils.isCreditCard('1234567890123456'); // Returns false (invalid)
Validates a credit card CVV (Card Verification Value).
The CVV to validate (3 or 4 digits)
True if the CVV format is valid, false otherwise
ValidationUtils.isCreditCardCvv('123'); // Returns true
ValidationUtils.isCreditCardCvv('1234'); // Returns true (Amex)
ValidationUtils.isCreditCardCvv('12'); // Returns false (too short)
Validates a credit card expiry date in MM/YY format.
The expiry date to validate in MM/YY format
True if the expiry date is valid and not in the past, false otherwise
ValidationUtils.isCreditCardExpiry('12/25'); // Returns true (if current date is before Dec 2025)
ValidationUtils.isCreditCardExpiry('01/20'); // Returns false (expired)
ValidationUtils.isCreditCardExpiry('13/25'); // Returns false (invalid month)
Validates a domain name format.
The domain name to validate
True if the domain name format is valid, false otherwise
ValidationUtils.isDomain('example.com'); // Returns true
ValidationUtils.isDomain('sub.example.org'); // Returns true
ValidationUtils.isDomain('invalid..domain'); // Returns false
Validates an email address format.
The email address to validate
True if the email format is valid, false otherwise
ValidationUtils.isEmail('user@example.com'); // Returns true
ValidationUtils.isEmail('test.email+tag@domain.co.uk'); // Returns true
ValidationUtils.isEmail('invalid-email'); // Returns false
Validates a hostname format.
The hostname to validate
True if the hostname format is valid, false otherwise
ValidationUtils.isHostname('localhost'); // Returns true
ValidationUtils.isHostname('web-server-01'); // Returns true
ValidationUtils.isHostname('invalid_hostname'); // Returns false
Checks if a value is empty (null, undefined, empty string, empty array, or empty object).
The value to check for emptiness
True if the value is considered empty, false otherwise
ValidationUtils.isEmpty(null); // Returns true
ValidationUtils.isEmpty(''); // Returns true
ValidationUtils.isEmpty([]); // Returns true
ValidationUtils.isEmpty({}); // Returns true
ValidationUtils.isEmpty('hello'); // Returns false
Validates an IP address (IPv4 or IPv6).
The IP address to validate
True if the IP address format is valid, false otherwise
ValidationUtils.isIpAddress('192.168.1.1'); // Returns true (IPv4)
ValidationUtils.isIpAddress('2001:0db8:85a3:0000:0000:8a2e:0370:7334'); // Returns true (IPv6)
ValidationUtils.isIpAddress('256.1.1.1'); // Returns false (invalid IPv4)
Validates if a string is valid JSON.
The JSON string to validate
True if the string is valid JSON, false otherwise
ValidationUtils.isJson('{"name": "John", "age": 30}'); // Returns true
ValidationUtils.isJson('[1, 2, 3]'); // Returns true
ValidationUtils.isJson('invalid json'); // Returns false
Validates a MIME type format.
The MIME type to validate
True if the MIME type format is valid, false otherwise
ValidationUtils.isMimeType('text/html'); // Returns true
ValidationUtils.isMimeType('application/json'); // Returns true
ValidationUtils.isMimeType('invalid-mime'); // Returns false
Validates password strength based on configurable criteria.
The password to validate
Password validation options
Optional
minMinimum password length (default: 8)
Optional
requireRequire uppercase letters (default: true)
Optional
requireRequire lowercase letters (default: true)
Optional
requireRequire numbers (default: true)
Optional
requireRequire special characters (default: true)
True if the password meets all criteria, false otherwise
ValidationUtils.isPassword('MyP@ssw0rd123'); // Returns true
ValidationUtils.isPassword('weak', { minLength: 4, requireSpecialChars: false }); // Returns false
ValidationUtils.isPassword('StrongPass123!'); // Returns true
Validates a phone number format.
The phone number to validate
True if the phone number format is valid, false otherwise
ValidationUtils.isPhoneNumber('+1 (555) 123-4567'); // Returns true
ValidationUtils.isPhoneNumber('555-123-4567'); // Returns true
ValidationUtils.isPhoneNumber('123'); // Returns false (too short)
Checks if a value is a valid username
Username to validate
Username validation options
Optional
minOptional
maxOptional
allowTrue if valid, false otherwise
Validation utility functions for common data types and formats