UNPKG

codetrix

Version:

A lightweight lodash-style utility library

63 lines (62 loc) 2.11 kB
/** * Validates whether a given string is in valid email format. * @param value - The string to validate. * @returns `true` if the string is a valid email, `false` otherwise. */ export declare function isEmail(value: string): boolean; /** * Checks whether the password is strong. * A strong password must contain at least: * - 8 characters * - 1 uppercase letter * - 1 lowercase letter * - 1 number * - 1 special character * * @param password - The password string to validate. * @returns `true` if strong, `false` otherwise. */ export declare function isStrongPassword(password: string): boolean; /** * Validates if a string is a valid international phone number. * Uses stricter E.164-like format: starts with optional +, 10-15 digits. * * @param phone - Phone number string. * @returns `true` if valid, `false` otherwise. */ export declare function isPhoneNumber(phone: string): boolean; /** * Validates a username. * Must be 3-16 characters long, alphanumeric and underscores only. * * @param username - The username string. * @returns `true` if valid, `false` otherwise. */ export declare function isUsername(username: string): boolean; /** * Validates a postal code based on the given country format. * * @param postalCode - The postal code to validate. * @param country - The country code ('US', 'IN', etc.). Defaults to 'US'. * @returns True if the postal code is valid for the given country, false otherwise. * * @example * isPostalCode("12345", "US") // true * isPostalCode("560001", "IN") // true */ export declare function isPostalCode(postalCode: string, country?: string): boolean; /** * Checks if the input is a valid credit card number using Luhn's algorithm * and real-world formatting rules. * * @param input - The credit card number string * @returns True if valid, else false */ export declare function isCreditCard(input: string): boolean; /** * Validates whether a given string is a valid URL. * * @param url - The URL string to validate. * @returns `true` if valid, `false` otherwise. */ export declare function isURL(url: string): boolean;