Socket
Socket
Sign inDemoInstall

@types/validator

Package Overview
Dependencies
0
Maintainers
1
Versions
79
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 12.0.0 to 12.0.1

2067

validator/index.d.ts

@@ -6,3 +6,3 @@ // Type definitions for validator.js 12.0

// Ayman Nedjmeddine <https://github.com/IOAyman>
// Louy Alakkad <https://github.com/louy>
// Louay Alakkad <https://github.com/louy>
// Kacper Polak <https://github.com/kacepe>

@@ -17,1235 +17,1234 @@ // Bonggyun Lee <https://github.com/deptno>

export const version: string;
declare namespace validator {
const version: string;
/******************
*** Validators ***
******************/
/******************
*** Validators ***
******************/
/**
* Check if the string contains the seed.
*
* @param seed - Seed
*/
export function contains(str: string, seed: any): boolean;
/**
* Check if the string contains the seed.
*
* @param seed - Seed
*/
function contains(str: string, seed: any): boolean;
/**
* Check if the string matches the comparison.
*
* @param comparison - String to compare
*/
export function equals(str: string, comparison: string): boolean;
/**
* Check if the string matches the comparison.
*
* @param comparison - String to compare
*/
function equals(str: string, comparison: string): boolean;
/**
* Check if the string is a date that's after the specified date.
*
* @param [date] - Date string (defaults to now)
*/
export function isAfter(str: string, date?: string): boolean;
/**
* Check if the string is a date that's after the specified date.
*
* @param [date] - Date string (defaults to now)
*/
function isAfter(str: string, date?: string): boolean;
export type AlphaLocale =
| 'en-US'
| 'bg-BG'
| 'cs-CZ'
| 'da-DK'
| 'de-DE'
| 'el-GR'
| 'es-ES'
| 'fr-FR'
| 'it-IT'
| 'nb-NO'
| 'nl-NL'
| 'nn-NO'
| 'hu-HU'
| 'pl-PL'
| 'pt-PT'
| 'ru-RU'
| 'sl-SI'
| 'sk-SK'
| 'sr-RS@latin'
| 'sr-RS'
| 'sv-SE'
| 'tr-TR'
| 'uk-UA'
| 'ku-IQ'
| 'ar'
| 'he'
| 'fa-IR'
| 'en-AU'
| 'en-GB'
| 'en-HK'
| 'en-IN'
| 'en-NZ'
| 'en-ZA'
| 'en-ZM'
| 'ar-AE'
| 'ar-BH'
| 'ar-DZ'
| 'ar-EG'
| 'ar-IQ'
| 'ar-JO'
| 'ar-KW'
| 'ar-LB'
| 'ar-LY'
| 'ar-MA'
| 'ar-QM'
| 'ar-QA'
| 'ar-SA'
| 'ar-SD'
| 'ar-SY'
| 'ar-TN'
| 'ar-YE'
| 'pt-BR'
| 'pl-Pl';
type AlphaLocale =
| 'en-US'
| 'bg-BG'
| 'cs-CZ'
| 'da-DK'
| 'de-DE'
| 'el-GR'
| 'es-ES'
| 'fr-FR'
| 'it-IT'
| 'nb-NO'
| 'nl-NL'
| 'nn-NO'
| 'hu-HU'
| 'pl-PL'
| 'pt-PT'
| 'ru-RU'
| 'sl-SI'
| 'sk-SK'
| 'sr-RS@latin'
| 'sr-RS'
| 'sv-SE'
| 'tr-TR'
| 'uk-UA'
| 'ku-IQ'
| 'ar'
| 'he'
| 'fa-IR'
| 'en-AU'
| 'en-GB'
| 'en-HK'
| 'en-IN'
| 'en-NZ'
| 'en-ZA'
| 'en-ZM'
| 'ar-AE'
| 'ar-BH'
| 'ar-DZ'
| 'ar-EG'
| 'ar-IQ'
| 'ar-JO'
| 'ar-KW'
| 'ar-LB'
| 'ar-LY'
| 'ar-MA'
| 'ar-QM'
| 'ar-QA'
| 'ar-SA'
| 'ar-SD'
| 'ar-SY'
| 'ar-TN'
| 'ar-YE'
| 'pt-BR'
| 'pl-Pl';
export const isAlphaLocales: AlphaLocale[];
const isAlphaLocales: AlphaLocale[];
/**
* Check if the string contains only letters (a-zA-Z).
*
* @param [locale] - AlphaLocale
*/
export function isAlpha(str: string, locale?: AlphaLocale): boolean;
export type AlphanumericLocale =
| 'en-US'
| 'bg-BG'
| 'cs-CZ'
| 'da-DK'
| 'de-DE'
| 'el-GR'
| 'es-ES'
| 'fr-FR'
| 'it-IT'
| 'hu-HU'
| 'nb-NO'
| 'nl-NL'
| 'nn-NO'
| 'pl-PL'
| 'pt-PT'
| 'ru-RU'
| 'sl-SI'
| 'sk-SK'
| 'sr-RS@latin'
| 'sr-RS'
| 'sv-SE'
| 'tr-TR'
| 'uk-UA'
| 'ku-IQ'
| 'ar'
| 'he'
| 'fa-IR'
| 'en-AU'
| 'en-GB'
| 'en-HK'
| 'en-IN'
| 'en-NZ'
| 'en-ZA'
| 'en-ZM'
| 'ar-AE'
| 'ar-BH'
| 'ar-DZ'
| 'ar-EG'
| 'ar-IQ'
| 'ar-JO'
| 'ar-KW'
| 'ar-LB'
| 'ar-LY'
| 'ar-MA'
| 'ar-QM'
| 'ar-QA'
| 'ar-SA'
| 'ar-SD'
| 'ar-SY'
| 'ar-TN'
| 'ar-YE'
| 'pt-BR'
| 'pl-Pl';
export const isAlphanumericLocales: AlphanumericLocale[];
/**
* Check if the string contains only letters and numbers.
*
* @param [locale] - AlphanumericLocale
*/
export function isAlphanumeric(str: string, locale?: AlphanumericLocale): boolean;
/**
* Check if the string contains ASCII chars only.
*/
export function isAscii(str: string): boolean;
/**
* Check if a string is base32 encoded.
*/
export function isBase32(str: string): boolean;
/**
* Check if a string is base64 encoded.
*/
export function isBase64(str: string): boolean;
/**
* Check if the string is a date that's before the specified date.
*
* @param [date] - Date string (defaults to now)
*/
export function isBefore(str: string, date?: string): boolean;
/**
* Check if a string is a BIC (Bank Identification Code) or SWIFT code.
*/
export function isBIC(str: string): boolean;
/**
* check if a string is a boolean.
*/
export function isBoolean(str: string): boolean;
export interface IsByteLengthOptions {
/**
* @default 0
* Check if the string contains only letters (a-zA-Z).
*
* @param [locale] - AlphaLocale
*/
min?: number;
/**
* @default undefined
*/
max?: number;
}
function isAlpha(str: string, locale?: AlphaLocale): boolean;
/**
* Check if the string's length (in UTF-8 bytes) falls in a range.
*
* @param [options] - Options
*/
export function isByteLength(str: string, options?: IsByteLengthOptions): boolean;
type AlphanumericLocale =
| 'en-US'
| 'bg-BG'
| 'cs-CZ'
| 'da-DK'
| 'de-DE'
| 'el-GR'
| 'es-ES'
| 'fr-FR'
| 'it-IT'
| 'hu-HU'
| 'nb-NO'
| 'nl-NL'
| 'nn-NO'
| 'pl-PL'
| 'pt-PT'
| 'ru-RU'
| 'sl-SI'
| 'sk-SK'
| 'sr-RS@latin'
| 'sr-RS'
| 'sv-SE'
| 'tr-TR'
| 'uk-UA'
| 'ku-IQ'
| 'ar'
| 'he'
| 'fa-IR'
| 'en-AU'
| 'en-GB'
| 'en-HK'
| 'en-IN'
| 'en-NZ'
| 'en-ZA'
| 'en-ZM'
| 'ar-AE'
| 'ar-BH'
| 'ar-DZ'
| 'ar-EG'
| 'ar-IQ'
| 'ar-JO'
| 'ar-KW'
| 'ar-LB'
| 'ar-LY'
| 'ar-MA'
| 'ar-QM'
| 'ar-QA'
| 'ar-SA'
| 'ar-SD'
| 'ar-SY'
| 'ar-TN'
| 'ar-YE'
| 'pt-BR'
| 'pl-Pl';
/**
* Check if the string is a credit card.
*/
export function isCreditCard(str: string): boolean;
const isAlphanumericLocales: AlphanumericLocale[];
export interface IsCurrencyOptions {
/**
* @default '$'
* Check if the string contains only letters and numbers.
*
* @param [locale] - AlphanumericLocale
*/
symbol?: string;
function isAlphanumeric(str: string, locale?: AlphanumericLocale): boolean;
/**
* @default false
* Check if the string contains ASCII chars only.
*/
require_symbol?: boolean;
function isAscii(str: string): boolean;
/**
* @default false
* Check if a string is base32 encoded.
*/
allow_space_after_symbol?: boolean;
function isBase32(str: string): boolean;
/**
* @default false
* Check if a string is base64 encoded.
*/
symbol_after_digits?: boolean;
function isBase64(str: string): boolean;
/**
* @default true
* Check if the string is a date that's before the specified date.
*
* @param [date] - Date string (defaults to now)
*/
allow_negatives?: boolean;
function isBefore(str: string, date?: string): boolean;
/**
* @default false
* Check if a string is a BIC (Bank Identification Code) or SWIFT code.
*/
parens_for_negatives?: boolean;
function isBIC(str: string): boolean;
/**
* @default false
* check if a string is a boolean.
*/
negative_sign_before_digits?: boolean;
function isBoolean(str: string): boolean;
interface IsByteLengthOptions {
/**
* @default 0
*/
min?: number;
/**
* @default undefined
*/
max?: number;
}
/**
* @default false
* Check if the string's length (in UTF-8 bytes) falls in a range.
*
* @param [options] - Options
*/
negative_sign_after_digits?: boolean;
function isByteLength(str: string, options?: IsByteLengthOptions): boolean;
/**
* @default false
* Check if the string is a credit card.
*/
allow_negative_sign_placeholder?: boolean;
function isCreditCard(str: string): boolean;
interface IsCurrencyOptions {
/**
* @default '$'
*/
symbol?: string;
/**
* @default false
*/
require_symbol?: boolean;
/**
* @default false
*/
allow_space_after_symbol?: boolean;
/**
* @default false
*/
symbol_after_digits?: boolean;
/**
* @default true
*/
allow_negatives?: boolean;
/**
* @default false
*/
parens_for_negatives?: boolean;
/**
* @default false
*/
negative_sign_before_digits?: boolean;
/**
* @default false
*/
negative_sign_after_digits?: boolean;
/**
* @default false
*/
allow_negative_sign_placeholder?: boolean;
/**
* @default ','
*/
thousands_separator?: string;
/**
* @default '.'
*/
decimal_separator?: string;
/**
* @default true
*/
allow_decimal?: boolean;
/**
* @default false
*/
require_decimal?: boolean;
/**
* The array `digits_after_decimal` is filled with the exact number of digits allowed not a range, for example a range `1` to `3` will be given as `[1, 2, 3]`.
*
* @default [2]
*/
digits_after_decimal?: number[];
/**
* @default false
*/
allow_space_after_digits?: boolean;
}
/**
* @default ','
* Check if the string is a valid currency amount.
*
* @param [options] - Options
*/
thousands_separator?: string;
function isCurrency(str: string, options?: IsCurrencyOptions): boolean;
/**
* @default '.'
* Check if the string is a [data uri format](https://developer.mozilla.org/en-US/docs/Web/HTTP/data_URIs).
*/
decimal_separator?: string;
function isDataURI(str: string): boolean;
type DecimalLocale = FloatLocale;
interface IsDecimalOptions {
/**
* @default false
*/
force_decimal?: boolean;
/**
* `decimal_digits` is given as a range like `'1,3'`,
* a specific value like `'3'` or min like `'1,'`
*
* @default '1,'
*/
decimal_digits?: string;
/**
* DecimalLocale
*
* @default 'en-US'
*/
locale?: DecimalLocale;
}
/**
* @default true
* Check if the string represents a decimal number,
* such as `0.1`, `.3`, `1.1`, `1.00003`, `4.0` etc.
*
* @param [options] - Options
*/
allow_decimal?: boolean;
function isDecimal(str: string, options?: IsDecimalOptions): boolean;
/**
* @default false
* Check if the string is a number that's divisible by another.
*
* @param number - Divider number
*/
require_decimal?: boolean;
function isDivisibleBy(str: string, number: number): boolean;
interface IsEmailOptions {
/**
* If `allow_display_name` is set to `true`, the validator will also match `Display Name <email-address>`.
*
* @default false
*/
allow_display_name?: boolean;
/**
* If `require_display_name` is set to `true`, the validator will reject strings without the format `Display Name <email-address>`.
*
* @default false
*/
require_display_name?: boolean;
/**
* If `allow_utf8_local_part` is set to `false`, the validator will not allow any non-English UTF8 character in email address' local part.
*
* @default true
*/
allow_utf8_local_part?: boolean;
/**
* If `require_tld` is set to `false`, e-mail addresses without having TLD in their domain will also be matched.
*
* @default true
*/
require_tld?: boolean;
/**
* If `ignore_max_length` is set to `true`, the validator will not check for the standard max length of an email.
*
* @default false
*/
ignore_max_length?: boolean;
/**
* If `allow_ip_domain` is set to `true`, the validator will allow IP addresses in the host part.
*
* @default false
*/
allow_ip_domain?: boolean;
/**
* If `domain_specific_validation` is `true`, some additional validation will be enabled,
* e.g. disallowing certain syntactically valid email addresses that are rejected by GMail.
*
* @default false
*/
domain_specific_validation?: boolean;
}
/**
* The array `digits_after_decimal` is filled with the exact number of digits allowed not a range, for example a range `1` to `3` will be given as `[1, 2, 3]`.
* Check if the string is an email.
*
* @default [2]
* @param [options] - Options
*/
digits_after_decimal?: number[];
function isEmail(str: string, options?: IsEmailOptions): boolean;
interface IsEmptyOptions {
/**
* @default false
*/
ignore_whitespace?: boolean;
}
/**
* @default false
* Check if the string has a length of zero.
*
* @param [options] - Options
*/
allow_space_after_digits?: boolean;
}
function isEmpty(str: string, options?: IsEmptyOptions): boolean;
/**
* Check if the string is a valid currency amount.
*
* @param [options] - Options
*/
export function isCurrency(str: string, options?: IsCurrencyOptions): boolean;
type FloatLocale =
| 'en-US'
| 'ar'
| 'en-AU'
| 'en-GB'
| 'en-HK'
| 'en-IN'
| 'en-NZ'
| 'en-ZA'
| 'en-ZM'
| 'ar-AE'
| 'ar-BH'
| 'ar-DZ'
| 'ar-EG'
| 'ar-IQ'
| 'ar-JO'
| 'ar-KW'
| 'ar-LB'
| 'ar-LY'
| 'ar-MA'
| 'ar-QM'
| 'ar-QA'
| 'ar-SA'
| 'ar-SD'
| 'ar-SY'
| 'ar-TN'
| 'ar-YE'
| 'bg-BG'
| 'cs-CZ'
| 'da-DK'
| 'de-DE'
| 'el-GR'
| 'es-ES'
| 'fr-FR'
| 'it-IT'
| 'ku-IQ'
| 'hu-HU'
| 'nb-NO'
| 'nn-NO'
| 'nl-NL'
| 'pl-PL'
| 'pt-PT'
| 'ru-RU'
| 'sl-SI'
| 'sr-RS@latin'
| 'sr-RS'
| 'sv-SE'
| 'tr-TR'
| 'uk-UA'
| 'pt-BR'
| 'pl-Pl';
/**
* Check if the string is a [data uri format](https://developer.mozilla.org/en-US/docs/Web/HTTP/data_URIs).
*/
export function isDataURI(str: string): boolean;
const isFloatLocales: FloatLocale[];
export type DecimalLocale = FloatLocale;
interface IsFloatOptions {
/**
* less or equal
*/
min?: number;
/**
* greater or equal
*/
max?: number;
/**
* greater than
*/
gt?: number;
/**
* less than
*/
lt?: number;
/**
* FloatLocale
*/
locale?: FloatLocale;
}
export interface IsDecimalOptions {
/**
* @default false
* Check if the string is a float.
*
* @param [options] - Options
*/
force_decimal?: boolean;
function isFloat(str: string, options?: IsFloatOptions): boolean;
interface IsFQDNOptions {
/**
* @default true
*/
require_tld?: boolean;
/**
* @default false
*/
allow_underscores?: boolean;
/**
* @default false
*/
allow_trailing_dot?: boolean;
}
/**
* `decimal_digits` is given as a range like `'1,3'`,
* a specific value like `'3'` or min like `'1,'`
* Check if the string is a fully qualified domain name (e.g. `domain.com`).
*
* @default '1,'
* @param [options] - Options
*/
decimal_digits?: string;
function isFQDN(str: string, options?: IsFQDNOptions): boolean;
/**
* DecimalLocale
*
* @default 'en-US'
* Check if the string contains any full-width chars.
*/
locale?: DecimalLocale;
}
function isFullWidth(str: string): boolean;
/**
* Check if the string represents a decimal number,
* such as `0.1`, `.3`, `1.1`, `1.00003`, `4.0` etc.
*
* @param [options] - Options
*/
export function isDecimal(str: string, options?: IsDecimalOptions): boolean;
/**
* Check if the string contains any half-width chars.
*/
function isHalfWidth(str: string): boolean;
/**
* Check if the string is a number that's divisible by another.
*
* @param number - Divider number
*/
export function isDivisibleBy(str: string, number: number): boolean;
type HashAlgorithm =
| 'md4'
| 'md5'
| 'sha1'
| 'sha256'
| 'sha384'
| 'sha512'
| 'ripemd128'
| 'ripemd160'
| 'tiger128'
| 'tiger160'
| 'tiger192'
| 'crc32'
| 'crc32b';
export interface IsEmailOptions {
/**
* If `allow_display_name` is set to `true`, the validator will also match `Display Name <email-address>`.
* Check if the string is a hash of type algorithm.
*
* @default false
* @param algorithm - HashAlgorithm
*/
allow_display_name?: boolean;
function isHash(str: string, algorithm: HashAlgorithm): boolean;
/**
* If `require_display_name` is set to `true`, the validator will reject strings without the format `Display Name <email-address>`.
*
* @default false
* Check if the string is a hexadecimal number.
*/
require_display_name?: boolean;
function isHexadecimal(str: string): boolean;
/**
* If `allow_utf8_local_part` is set to `false`, the validator will not allow any non-English UTF8 character in email address' local part.
*
* @default true
* Check if the string is a hexadecimal color.
*/
allow_utf8_local_part?: boolean;
function isHexColor(str: string): boolean;
type IdentityCardLocale = 'ES' | 'he-IL' | 'zh-TW';
/**
* If `require_tld` is set to `false`, e-mail addresses without having TLD in their domain will also be matched.
* Check if the string is a valid identity card code.
*
* @default true
* @param [locale="any"] - IdentityCardLocale
*/
require_tld?: boolean;
function isIdentityCard(str: string, locale?: 'any' | IdentityCardLocale): boolean;
/**
* If `ignore_max_length` is set to `true`, the validator will not check for the standard max length of an email.
* Check if the string is in a array of allowed values.
*
* @default false
* @param values - Allowed values.
*/
ignore_max_length?: boolean;
function isIn(str: string, values: any[]): boolean;
interface IsIntOptions {
/**
* to check the integer min boundary
*/
min?: number;
/**
* to check the integer max boundary
*/
max?: number;
/**
* if `false`, will disallow integer values with leading zeroes
* @default true
*/
allow_leading_zeroes?: boolean;
/**
* enforce integers being greater than the value provided
*/
lt?: number;
/**
* enforce integers being less than the value provided
*/
gt?: number;
}
/**
* If `allow_ip_domain` is set to `true`, the validator will allow IP addresses in the host part.
* Check if the string is an integer.
*
* @default false
* @param [options] - Options
*/
allow_ip_domain?: boolean;
function isInt(str: string, options?: IsIntOptions): boolean;
/**
* If `domain_specific_validation` is `true`, some additional validation will be enabled,
* e.g. disallowing certain syntactically valid email addresses that are rejected by GMail.
* Check if the string is an IP (version 4 or 6).
*
* @default false
* @param [version] - IP Version
*/
domain_specific_validation?: boolean;
}
function isIP(str: string, version?: '4' | '6'): boolean;
/**
* Check if the string is an email.
*
* @param [options] - Options
*/
export function isEmail(str: string, options?: IsEmailOptions): boolean;
export interface IsEmptyOptions {
/**
* @default false
* Check if the string is an IP Range (version 4 only).
*/
ignore_whitespace?: boolean;
}
function isIPRange(str: string): boolean;
/**
* Check if the string has a length of zero.
*
* @param [options] - Options
*/
export function isEmpty(str: string, options?: IsEmptyOptions): boolean;
export type FloatLocale =
| 'en-US'
| 'ar'
| 'en-AU'
| 'en-GB'
| 'en-HK'
| 'en-IN'
| 'en-NZ'
| 'en-ZA'
| 'en-ZM'
| 'ar-AE'
| 'ar-BH'
| 'ar-DZ'
| 'ar-EG'
| 'ar-IQ'
| 'ar-JO'
| 'ar-KW'
| 'ar-LB'
| 'ar-LY'
| 'ar-MA'
| 'ar-QM'
| 'ar-QA'
| 'ar-SA'
| 'ar-SD'
| 'ar-SY'
| 'ar-TN'
| 'ar-YE'
| 'bg-BG'
| 'cs-CZ'
| 'da-DK'
| 'de-DE'
| 'el-GR'
| 'es-ES'
| 'fr-FR'
| 'it-IT'
| 'ku-IQ'
| 'hu-HU'
| 'nb-NO'
| 'nn-NO'
| 'nl-NL'
| 'pl-PL'
| 'pt-PT'
| 'ru-RU'
| 'sl-SI'
| 'sr-RS@latin'
| 'sr-RS'
| 'sv-SE'
| 'tr-TR'
| 'uk-UA'
| 'pt-BR'
| 'pl-Pl';
export const isFloatLocales: FloatLocale[];
export interface IsFloatOptions {
/**
* less or equal
* Check if the string is an ISBN (version 10 or 13).
*
* @param [version] - ISBN Version
*/
min?: number;
function isISBN(str: string, version?: '10' | '13'): boolean;
/**
* greater or equal
* Check if the string is an [ISIN](https://en.wikipedia.org/wiki/International_Securities_Identification_Number) (stock/security identifier).
*/
max?: number;
function isISIN(str: string): boolean;
/**
* greater than
* Check if the string is a valid [ISO 3166-1 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) officially assigned country code.
*/
gt?: number;
function isISO31661Alpha2(str: string): boolean;
/**
* less than
* Check if the string is a valid [ISO 3166-1 alpha-3](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-3) officially assigned country code.
*/
lt?: number;
function isISO31661Alpha3(str: string): boolean;
interface IsISO8601Options {
/**
* If `strict` is `true`, performs additional checks for valid dates,
* e.g. invalidates dates like `2009-02-29`.
*
* @default false
*/
strict?: boolean;
}
/**
* FloatLocale
* Check if the string is a valid [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) date.
*
* @param [options] - Options
*/
locale?: FloatLocale;
}
function isISO8601(str: string, options?: IsISO8601Options): boolean;
/**
* Check if the string is a float.
*
* @param [options] - Options
*/
export function isFloat(str: string, options?: IsFloatOptions): boolean;
interface IsISSNOptions {
/**
* If `case_sensitive` is `true`, ISSNs with a lowercase `x` as the check digit are rejected.
*
* @default false
*/
case_sensitive?: boolean;
/**
* @default false
*/
require_hyphen?: boolean;
}
export interface IsFQDNOptions {
/**
* @default true
* Check if the string is an [ISSN](https://en.wikipedia.org/wiki/International_Standard_Serial_Number).
*
* @param [options] - Options
*/
require_tld?: boolean;
function isISSN(str: string, options?: IsISSNOptions): boolean;
/**
* @default false
* Check if the string is a [ISRC](https://en.wikipedia.org/wiki/International_Standard_Recording_Code).
*/
allow_underscores?: boolean;
function isISRC(str: string): boolean;
/**
* @default false
* Check if the string is a valid [RFC 3339](https://tools.ietf.org/html/rfc3339) date.
*/
allow_trailing_dot?: boolean;
}
function isRFC3339(str: string): boolean;
/**
* Check if the string is a fully qualified domain name (e.g. `domain.com`).
*
* @param [options] - Options
*/
export function isFQDN(str: string, options?: IsFQDNOptions): boolean;
/**
* Check if the string contains any full-width chars.
*/
export function isFullWidth(str: string): boolean;
/**
* Check if the string contains any half-width chars.
*/
export function isHalfWidth(str: string): boolean;
export type HashAlgorithm =
| 'md4'
| 'md5'
| 'sha1'
| 'sha256'
| 'sha384'
| 'sha512'
| 'ripemd128'
| 'ripemd160'
| 'tiger128'
| 'tiger160'
| 'tiger192'
| 'crc32'
| 'crc32b';
/**
* Check if the string is a hash of type algorithm.
*
* @param algorithm - HashAlgorithm
*/
export function isHash(str: string, algorithm: HashAlgorithm): boolean;
/**
* Check if the string is a hexadecimal number.
*/
export function isHexadecimal(str: string): boolean;
/**
* Check if the string is a hexadecimal color.
*/
export function isHexColor(str: string): boolean;
export type IdentityCardLocale = 'ES' | 'he-IL' | 'zh-TW';
/**
* Check if the string is a valid identity card code.
*
* @param [locale="any"] - IdentityCardLocale
*/
export function isIdentityCard(str: string, locale?: 'any' | IdentityCardLocale): boolean;
/**
* Check if the string is in a array of allowed values.
*
* @param values - Allowed values.
*/
export function isIn(str: string, values: any[]): boolean;
export interface IsIntOptions {
/**
* to check the integer min boundary
* Check if the string is valid JSON (note: uses `JSON.parse`).
*/
min?: number;
function isJSON(str: string): boolean;
/**
* to check the integer max boundary
* Check if the string is valid JWT token.
*/
max?: number;
function isJWT(str: string): boolean;
/**
* if `false`, will disallow integer values with leading zeroes
* @default true
* Check if the string is a valid latitude-longitude coordinate in the format:
*
* `lat,long` or `lat, long`.
*/
allow_leading_zeroes?: boolean;
function isLatLong(str: string): boolean;
interface IsLengthOptions {
/**
* @default 0
*/
min?: number;
/**
* @default undefined
*/
max?: number;
}
/**
* enforce integers being greater than the value provided
* Check if the string's length falls in a range.
*
* Note: this function takes into account surrogate pairs.
*
* @param [options] - Options
*/
lt?: number;
function isLength(str: string, options?: IsLengthOptions): boolean;
/**
* enforce integers being less than the value provided
* Check if the string is lowercase.
*/
gt?: number;
}
function isLowercase(str: string): boolean;
/**
* Check if the string is an integer.
*
* @param [options] - Options
*/
export function isInt(str: string, options?: IsIntOptions): boolean;
interface IsMACAddressOptions {
/**
* If `no_colons` is `true`, the validator will allow MAC addresses without the colons.
* Also, it allows the use of hyphens or spaces.
*
* e.g. `01 02 03 04 05 ab` or `01-02-03-04-05-ab`.
*
* @default false
*/
no_colons?: boolean;
}
/**
* Check if the string is an IP (version 4 or 6).
*
* @param [version] - IP Version
*/
export function isIP(str: string, version?: '4' | '6'): boolean;
/**
* Check if the string is an IP Range (version 4 only).
*/
export function isIPRange(str: string): boolean;
/**
* Check if the string is an ISBN (version 10 or 13).
*
* @param [version] - ISBN Version
*/
export function isISBN(str: string, version?: '10' | '13'): boolean;
/**
* Check if the string is an [ISIN](https://en.wikipedia.org/wiki/International_Securities_Identification_Number) (stock/security identifier).
*/
export function isISIN(str: string): boolean;
/**
* Check if the string is a valid [ISO 3166-1 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) officially assigned country code.
*/
export function isISO31661Alpha2(str: string): boolean;
/**
* Check if the string is a valid [ISO 3166-1 alpha-3](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-3) officially assigned country code.
*/
export function isISO31661Alpha3(str: string): boolean;
export interface IsISO8601Options {
/**
* If `strict` is `true`, performs additional checks for valid dates,
* e.g. invalidates dates like `2009-02-29`.
* Check if the string is a MAC address.
*
* @default false
* @param [options] - Options
*/
strict?: boolean;
}
function isMACAddress(str: string, options?: IsMACAddressOptions): boolean;
/**
* Check if the string is a valid [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) date.
*
* @param [options] - Options
*/
export function isISO8601(str: string, options?: IsISO8601Options): boolean;
/**
* Check if the string is a [magnet uri format](https://en.wikipedia.org/wiki/Magnet_URI_scheme).
*/
function isMagnetURI(str: string): boolean;
export interface IsISSNOptions {
/**
* If `case_sensitive` is `true`, ISSNs with a lowercase `x` as the check digit are rejected.
*
* @default false
* Check if the string is a MD5 hash.
*/
case_sensitive?: boolean;
function isMD5(str: string): boolean;
/**
* @default false
* Check if the string matches to a valid [MIME type](https://en.wikipedia.org/wiki/Media_type) format.
*/
require_hyphen?: boolean;
}
function isMimeType(str: string): boolean;
/**
* Check if the string is an [ISSN](https://en.wikipedia.org/wiki/International_Standard_Serial_Number).
*
* @param [options] - Options
*/
export function isISSN(str: string, options?: IsISSNOptions): boolean;
type MobilePhoneLocale =
| 'ar-AE'
| 'ar-BH'
| 'ar-DZ'
| 'ar-EG'
| 'ar-IQ'
| 'ar-JO'
| 'ar-KW'
| 'ar-SA'
| 'ar-SY'
| 'ar-TN'
| 'be-BY'
| 'bg-BG'
| 'bn-BD'
| 'cs-CZ'
| 'da-DK'
| 'de-DE'
| 'de-AT'
| 'el-GR'
| 'en-AU'
| 'en-GB'
| 'en-GG'
| 'en-GH'
| 'en-HK'
| 'en-IE'
| 'en-IN'
| 'en-KE'
| 'en-MT'
| 'en-MU'
| 'en-NG'
| 'en-NZ'
| 'en-PK'
| 'en-RW'
| 'en-SG'
| 'en-TZ'
| 'en-UG'
| 'en-US'
| 'en-ZA'
| 'en-ZM'
| 'es-CL'
| 'es-ES'
| 'es-MX'
| 'es-PA'
| 'es-PY'
| 'es-UY'
| 'et-EE'
| 'fa-IR'
| 'fi-FI'
| 'fj-FJ'
| 'fo-FO'
| 'fr-FR'
| 'fr-GF'
| 'fr-GP'
| 'fr-MQ'
| 'fr-RE'
| 'he-IL'
| 'hu-HU'
| 'id-ID'
| 'it-IT'
| 'ja-JP'
| 'kk-KZ'
| 'kl-GL'
| 'ko-KR'
| 'lt-LT'
| 'ms-MY'
| 'nb-NO'
| 'nl-BE'
| 'nl-NL'
| 'nn-NO'
| 'pl-PL'
| 'pt-BR'
| 'pt-PT'
| 'ro-RO'
| 'ru-RU'
| 'sl-SI'
| 'sk-SK'
| 'sr-RS'
| 'sv-SE'
| 'th-TH'
| 'tr-TR'
| 'uk-UA'
| 'vi-VN'
| 'zh-CN'
| 'zh-TW'
| 'en-CA'
| 'fr-BE'
| 'zh-HK';
/**
* Check if the string is a [ISRC](https://en.wikipedia.org/wiki/International_Standard_Recording_Code).
*/
export function isISRC(str: string): boolean;
const isMobilePhoneLocales: MobilePhoneLocale[];
/**
* Check if the string is a valid [RFC 3339](https://tools.ietf.org/html/rfc3339) date.
*/
export function isRFC3339(str: string): boolean;
interface IsMobilePhoneOptions {
/**
* If this is set to `true`, the mobile phone number must be supplied with the country code and therefore must start with `+`.
*
* @default false
*/
strictMode?: boolean;
}
/**
* Check if the string is valid JSON (note: uses `JSON.parse`).
*/
export function isJSON(str: string): boolean;
/**
* Check if the string is a mobile phone number.
*
* @param [locale] - MobilePhoneLocale(s)
* @param [options] - Options
*/
function isMobilePhone(
str: string,
locale?: 'any' | MobilePhoneLocale | MobilePhoneLocale[],
options?: IsMobilePhoneOptions,
): boolean;
/**
* Check if the string is valid JWT token.
*/
export function isJWT(str: string): boolean;
/**
* Check if the string is a valid latitude-longitude coordinate in the format:
*
* `lat,long` or `lat, long`.
*/
export function isLatLong(str: string): boolean;
export interface IsLengthOptions {
/**
* @default 0
* Check if the string is a valid hex-encoded representation of a [MongoDB ObjectId](http://docs.mongodb.org/manual/reference/object-id/).
*/
min?: number;
function isMongoId(str: string): boolean;
/**
* @default undefined
* Check if the string contains one or more multibyte chars.
*/
max?: number;
}
function isMultibyte(str: string): boolean;
/**
* Check if the string's length falls in a range.
*
* Note: this function takes into account surrogate pairs.
*
* @param [options] - Options
*/
export function isLength(str: string, options?: IsLengthOptions): boolean;
interface IsNumericOptions {
/**
* If `no_symbols` is true, the validator will reject numeric strings that feature a symbol (e.g. `+`, `-`, or `.`).
*
* @default false
*/
no_symbols?: boolean;
}
/**
* Check if the string is lowercase.
*/
export function isLowercase(str: string): boolean;
export interface IsMACAddressOptions {
/**
* If `no_colons` is `true`, the validator will allow MAC addresses without the colons.
* Also, it allows the use of hyphens or spaces.
* Check if the string contains only numbers.
*
* e.g. `01 02 03 04 05 ab` or `01-02-03-04-05-ab`.
*
* @default false
* @param [options] - Options
*/
no_colons?: boolean;
}
function isNumeric(str: string, options?: IsNumericOptions): boolean;
/**
* Check if the string is a MAC address.
*
* @param [options] - Options
*/
export function isMACAddress(str: string, options?: IsMACAddressOptions): boolean;
/**
* Check if the string is a valid octal number.
*/
function isOctal(str: string): boolean;
/**
* Check if the string is a [magnet uri format](https://en.wikipedia.org/wiki/Magnet_URI_scheme).
*/
export function isMagnetURI(str: string): boolean;
/**
* Check if the string is a valid port number.
*/
function isPort(str: string): boolean;
/**
* Check if the string is a MD5 hash.
*/
export function isMD5(str: string): boolean;
type PostalCodeLocale =
| 'AD'
| 'AT'
| 'AU'
| 'BE'
| 'BG'
| 'BR'
| 'CA'
| 'CH'
| 'CZ'
| 'DE'
| 'DK'
| 'DZ'
| 'EE'
| 'ES'
| 'FI'
| 'FR'
| 'GB'
| 'GR'
| 'HR'
| 'HU'
| 'ID'
| 'IE'
| 'IL'
| 'IN'
| 'IS'
| 'IT'
| 'JP'
| 'KE'
| 'LI'
| 'LT'
| 'LU'
| 'LV'
| 'MX'
| 'MT'
| 'NL'
| 'NO'
| 'NZ'
| 'PL'
| 'PR'
| 'PT'
| 'RO'
| 'RU'
| 'SA'
| 'SE'
| 'SI'
| 'SK'
| 'TN'
| 'TW'
| 'UA'
| 'US'
| 'ZA'
| 'ZM';
/**
* Check if the string matches to a valid [MIME type](https://en.wikipedia.org/wiki/Media_type) format.
*/
export function isMimeType(str: string): boolean;
const isPostalCodeLocales: PostalCodeLocale[];
export type MobilePhoneLocale =
| 'ar-AE'
| 'ar-BH'
| 'ar-DZ'
| 'ar-EG'
| 'ar-IQ'
| 'ar-JO'
| 'ar-KW'
| 'ar-SA'
| 'ar-SY'
| 'ar-TN'
| 'be-BY'
| 'bg-BG'
| 'bn-BD'
| 'cs-CZ'
| 'da-DK'
| 'de-DE'
| 'de-AT'
| 'el-GR'
| 'en-AU'
| 'en-GB'
| 'en-GG'
| 'en-GH'
| 'en-HK'
| 'en-IE'
| 'en-IN'
| 'en-KE'
| 'en-MT'
| 'en-MU'
| 'en-NG'
| 'en-NZ'
| 'en-PK'
| 'en-RW'
| 'en-SG'
| 'en-TZ'
| 'en-UG'
| 'en-US'
| 'en-ZA'
| 'en-ZM'
| 'es-CL'
| 'es-ES'
| 'es-MX'
| 'es-PA'
| 'es-PY'
| 'es-UY'
| 'et-EE'
| 'fa-IR'
| 'fi-FI'
| 'fj-FJ'
| 'fo-FO'
| 'fr-FR'
| 'fr-GF'
| 'fr-GP'
| 'fr-MQ'
| 'fr-RE'
| 'he-IL'
| 'hu-HU'
| 'id-ID'
| 'it-IT'
| 'ja-JP'
| 'kk-KZ'
| 'kl-GL'
| 'ko-KR'
| 'lt-LT'
| 'ms-MY'
| 'nb-NO'
| 'nl-BE'
| 'nl-NL'
| 'nn-NO'
| 'pl-PL'
| 'pt-BR'
| 'pt-PT'
| 'ro-RO'
| 'ru-RU'
| 'sl-SI'
| 'sk-SK'
| 'sr-RS'
| 'sv-SE'
| 'th-TH'
| 'tr-TR'
| 'uk-UA'
| 'vi-VN'
| 'zh-CN'
| 'zh-TW'
| 'en-CA'
| 'fr-BE'
| 'zh-HK';
export const isMobilePhoneLocales: MobilePhoneLocale[];
export interface IsMobilePhoneOptions {
/**
* If this is set to `true`, the mobile phone number must be supplied with the country code and therefore must start with `+`.
* Check if the string is a postal code
*
* @default false
* @param locale - PostalCodeLocale
*/
strictMode?: boolean;
}
function isPostalCode(str: string, locale: 'any' | PostalCodeLocale): boolean;
/**
* Check if the string is a mobile phone number.
*
* @param [locale] - MobilePhoneLocale(s)
* @param [options] - Options
*/
export function isMobilePhone(
str: string,
locale?: 'any' | MobilePhoneLocale | MobilePhoneLocale[],
options?: IsMobilePhoneOptions,
): boolean;
/**
* Check if the string contains any surrogate pairs chars.
*/
function isSurrogatePair(str: string): boolean;
/**
* Check if the string is a valid hex-encoded representation of a [MongoDB ObjectId](http://docs.mongodb.org/manual/reference/object-id/).
*/
export function isMongoId(str: string): boolean;
interface IsURLOptions {
/**
* @default ['http','https','ftp']
*/
protocols?: string[];
/**
* @default true
*/
require_tld?: boolean;
/**
* @default false
*/
require_protocol?: boolean;
/**
* @default true
*/
require_host?: boolean;
/**
* @default true
*/
require_valid_protocol?: boolean;
/**
* @default false
*/
allow_underscores?: boolean;
/**
* @default false
*/
host_whitelist?: Array<string | RegExp>;
/**
* @default false
*/
host_blacklist?: Array<string | RegExp>;
/**
* @default false
*/
allow_trailing_dot?: boolean;
/**
* @default false
*/
allow_protocol_relative_urls?: boolean;
/**
* @default false
*/
disallow_auth?: boolean;
}
/**
* Check if the string contains one or more multibyte chars.
*/
export function isMultibyte(str: string): boolean;
export interface IsNumericOptions {
/**
* If `no_symbols` is true, the validator will reject numeric strings that feature a symbol (e.g. `+`, `-`, or `.`).
* Check if the string is an URL.
*
* @default false
* @param [options] - Options
*/
no_symbols?: boolean;
}
function isURL(str: string, options?: IsURLOptions): boolean;
/**
* Check if the string contains only numbers.
*
* @param [options] - Options
*/
export function isNumeric(str: string, options?: IsNumericOptions): boolean;
/**
* Check if the string is a valid octal number.
*/
export function isOctal(str: string): boolean;
/**
* Check if the string is a valid port number.
*/
export function isPort(str: string): boolean;
export type PostalCodeLocale =
| 'AD'
| 'AT'
| 'AU'
| 'BE'
| 'BG'
| 'BR'
| 'CA'
| 'CH'
| 'CZ'
| 'DE'
| 'DK'
| 'DZ'
| 'EE'
| 'ES'
| 'FI'
| 'FR'
| 'GB'
| 'GR'
| 'HR'
| 'HU'
| 'ID'
| 'IE'
| 'IL'
| 'IN'
| 'IS'
| 'IT'
| 'JP'
| 'KE'
| 'LI'
| 'LT'
| 'LU'
| 'LV'
| 'MX'
| 'MT'
| 'NL'
| 'NO'
| 'NZ'
| 'PL'
| 'PR'
| 'PT'
| 'RO'
| 'RU'
| 'SA'
| 'SE'
| 'SI'
| 'SK'
| 'TN'
| 'TW'
| 'UA'
| 'US'
| 'ZA'
| 'ZM';
export const isPostalCodeLocales: PostalCodeLocale[];
/**
* Check if the string is a postal code
*
* @param locale - PostalCodeLocale
*/
export function isPostalCode(str: string, locale: 'any' | PostalCodeLocale): boolean;
/**
* Check if the string contains any surrogate pairs chars.
*/
export function isSurrogatePair(str: string): boolean;
export interface IsURLOptions {
/**
* @default ['http','https','ftp']
* Check if the string is uppercase.
*/
protocols?: string[];
function isUppercase(str: string): boolean;
/**
* @default true
* Check if the string is a UUID (version 3, 4 or 5).
*
* @param [version="all"] - UUID version
*/
require_tld?: boolean;
function isUUID(str: string, version?: 3 | 4 | 5 | '3' | '4' | '5' | 'all'): boolean;
/**
* @default false
* Check if the string contains a mixture of full and half-width chars.
*/
require_protocol?: boolean;
function isVariableWidth(str: string): boolean;
/**
* @default true
* Checks characters if they appear in the whitelist.
*
* @param chars - whitelist
*/
require_host?: boolean;
function isWhitelisted(str: string, chars: string | string[]): boolean;
/**
* @default true
* Check if string matches the pattern.
*
* @param pattern - `/foo/i`
*/
require_valid_protocol?: boolean;
function matches(str: string, pattern: RegExp): boolean;
/**
* @default false
* Check if string matches the pattern.
*
* @param pattern - `'foo'`
* @param [modifiers] - `'i'`
*/
allow_underscores?: boolean;
function matches(str: string, pattern: string, modifiers?: string): boolean;
/**
* @default false
* Check if the string is of type slug.
*/
host_whitelist?: Array<string | RegExp>;
function isSlug(str: string): boolean;
/******************
*** Sanitizers ***
******************/
/**
* @default false
* Remove characters that appear in the blacklist.
*
* @param chars - The characters are used in a `RegExp` and so you will need to escape some chars, e.g. `blacklist(input, '\\[\\]')`.
*/
host_blacklist?: Array<string | RegExp>;
function blacklist(input: string, chars: string): string;
/**
* @default false
* Replace `<`, `>`, `&`, `'`, `"` and `/` with HTML entities.
*/
allow_trailing_dot?: boolean;
function escape(input: string): string;
/**
* @default false
* Replaces HTML encoded entities with `<`, `>`, `&`, `'`, `"` and `/`.
*/
allow_protocol_relative_urls?: boolean;
function unescape(input: string): string;
/**
* @default false
* Trim characters from the left-side of the input.
*
* @param [chars] - characters (defaults to whitespace)
*/
disallow_auth?: boolean;
}
function ltrim(input: string, chars?: string): string;
/**
* Check if the string is an URL.
*
* @param [options] - Options
*/
export function isURL(str: string, options?: IsURLOptions): boolean;
interface NormalizeEmailOptions {
/**
* Transforms the local part (before the @ symbol) of all email addresses to lowercase.
* Please note that this may violate RFC 5321, which gives providers the possibility
* to treat the local part of email addresses in a case sensitive way
* (although in practice most - yet not all - providers don't).
* The domain part of the email address is always lowercased, as it's case insensitive per RFC 1035.
*
* @default true
*/
all_lowercase?: boolean;
/**
* GMail addresses are known to be case-insensitive, so this switch allows lowercasing them even when `all_lowercase` is set to `false`.
* Please note that when `all_lowercase` is `true`, GMail addresses are lowercased regardless of the value of this setting.
*
* @default true
*/
gmail_lowercase?: boolean;
/**
* Removes dots from the local part of the email address, as GMail ignores them
* (e.g. `"john.doe"` and `"johndoe"` are considered equal).
*
* @default true
*/
gmail_remove_dots?: boolean;
/**
* Normalizes addresses by removing "sub-addresses", which is the part following a `"+"` sign
* (e.g. `"foo+bar@gmail.com"` becomes `"foo@gmail.com"`).
*
* @default true
*/
gmail_remove_subaddress?: boolean;
/**
* Converts addresses with domain `@googlemail.com` to `@gmail.com`, as they're equivalent.
*
* @default true
*/
gmail_convert_googlemaildotcom?: boolean;
/**
* Outlook.com addresses (including Windows Live and Hotmail) are known to be case-insensitive, so this switch allows lowercasing them even when `all_lowercase` is set to `false`.
* Please note that when `all_lowercase` is `true`, Outlook.com addresses are lowercased regardless of the value of this setting.
*
* @default true
*/
outlookdotcom_lowercase?: boolean;
/**
* Normalizes addresses by removing "sub-addresses", which is the part following a `"+"` sign
* (e.g. `"foo+bar@outlook.com"` becomes `"foo@outlook.com"`).
*
* @default true
*/
outlookdotcom_remove_subaddress?: boolean;
/**
* Yahoo Mail addresses are known to be case-insensitive, so this switch allows lowercasing them even when `all_lowercase` is set to `false`.
* Please note that when `all_lowercase` is `true`, Yahoo Mail addresses are lowercased regardless of the value of this setting.
*
* @default true
*/
yahoo_lowercase?: boolean;
/**
* Normalizes addresses by removing "sub-addresses", which is the part following a `"-"` sign
* (e.g. `"foo-bar@yahoo.com"` becomes `"foo@yahoo.com"`).
*
* @default true
*/
yahoo_remove_subaddress?: boolean;
/**
* iCloud addresses (including MobileMe) are known to be case-insensitive, so this switch allows lowercasing them even when `all_lowercase` is set to `false`.
* Please note that when `all_lowercase` is `true`, iCloud addresses are lowercased regardless of the value of this setting.
*
* @default true
*/
icloud_lowercase?: boolean;
/**
* Normalizes addresses by removing "sub-addresses", which is the part following a `"+"` sign
* (e.g. `"foo+bar@icloud.com"` becomes `"foo@icloud.com"`).
*
* @default true
*/
icloud_remove_subaddress?: boolean;
}
/**
* Check if the string is uppercase.
*/
export function isUppercase(str: string): boolean;
/**
* Check if the string is a UUID (version 3, 4 or 5).
*
* @param [version="all"] - UUID version
*/
export function isUUID(str: string, version?: 3 | 4 | 5 | '3' | '4' | '5' | 'all'): boolean;
/**
* Check if the string contains a mixture of full and half-width chars.
*/
export function isVariableWidth(str: string): boolean;
/**
* Checks characters if they appear in the whitelist.
*
* @param chars - whitelist
*/
export function isWhitelisted(str: string, chars: string | string[]): boolean;
/**
* Check if string matches the pattern.
*
* @param pattern - `/foo/i`
*/
export function matches(str: string, pattern: RegExp): boolean;
/**
* Check if string matches the pattern.
*
* @param pattern - `'foo'`
* @param [modifiers] - `'i'`
*/
export function matches(str: string, pattern: string, modifiers?: string): boolean;
/**
* Check if the string is of type slug.
*/
export function isSlug(str: string): boolean;
/******************
*** Sanitizers ***
******************/
/**
* Remove characters that appear in the blacklist.
*
* @param chars - The characters are used in a `RegExp` and so you will need to escape some chars, e.g. `blacklist(input, '\\[\\]')`.
*/
export function blacklist(input: string, chars: string): string;
/**
* Replace `<`, `>`, `&`, `'`, `"` and `/` with HTML entities.
*/
export function escape(input: string): string;
/**
* Replaces HTML encoded entities with `<`, `>`, `&`, `'`, `"` and `/`.
*/
export function unescape(input: string): string;
/**
* Trim characters from the left-side of the input.
*
* @param [chars] - characters (defaults to whitespace)
*/
export function ltrim(input: string, chars?: string): string;
export interface NormalizeEmailOptions {
/**
* Transforms the local part (before the @ symbol) of all email addresses to lowercase.
* Please note that this may violate RFC 5321, which gives providers the possibility
* to treat the local part of email addresses in a case sensitive way
* (although in practice most - yet not all - providers don't).
* The domain part of the email address is always lowercased, as it's case insensitive per RFC 1035.
* Canonicalizes an email address. (This doesn't validate that the input is an email, if you want to validate the email use `isEmail` beforehand)
*
* @default true
* @param [options] - Options
*/
all_lowercase?: boolean;
function normalizeEmail(email: string, options?: NormalizeEmailOptions): string | false;
/**
* GMail addresses are known to be case-insensitive, so this switch allows lowercasing them even when `all_lowercase` is set to `false`.
* Please note that when `all_lowercase` is `true`, GMail addresses are lowercased regardless of the value of this setting.
* Trim characters from the right-side of the input.
*
* @default true
* @param [chars] - characters (defaults to whitespace)
*/
gmail_lowercase?: boolean;
function rtrim(input: string, chars?: string): string;
/**
* Removes dots from the local part of the email address, as GMail ignores them
* (e.g. `"john.doe"` and `"johndoe"` are considered equal).
* Remove characters with a numerical value < `32` and `127`, mostly control characters.
* Unicode-safe in JavaScript.
*
* @default true
* @param [keep_new_lines=false] - if `true`, newline characters are preserved (`\n` and `\r`, hex `0xA` and `0xD`).
*/
gmail_remove_dots?: boolean;
function stripLow(input: string, keep_new_lines?: boolean): string;
/**
* Normalizes addresses by removing "sub-addresses", which is the part following a `"+"` sign
* (e.g. `"foo+bar@gmail.com"` becomes `"foo@gmail.com"`).
* Convert the input string to a boolean.
* Everything except for `'0'`, `'false'` and `''` returns `true`.
*
* @default true
* @param [strict=false] - in `strict` mode, only `'1'` and `'true'` return `true`.
*/
gmail_remove_subaddress?: boolean;
function toBoolean(input: string, strict?: boolean): boolean;
/**
* Converts addresses with domain `@googlemail.com` to `@gmail.com`, as they're equivalent.
*
* @default true
* Convert the input string to a `Date`, or `null` if the input is not a date.
*/
gmail_convert_googlemaildotcom?: boolean;
function toDate(input: string): Date | null;
/**
* Outlook.com addresses (including Windows Live and Hotmail) are known to be case-insensitive, so this switch allows lowercasing them even when `all_lowercase` is set to `false`.
* Please note that when `all_lowercase` is `true`, Outlook.com addresses are lowercased regardless of the value of this setting.
*
* @default true
* Convert the input string to a float, or `NaN` if the input is not a float.
*/
outlookdotcom_lowercase?: boolean;
function toFloat(input: string): number;
/**
* Normalizes addresses by removing "sub-addresses", which is the part following a `"+"` sign
* (e.g. `"foo+bar@outlook.com"` becomes `"foo@outlook.com"`).
* Convert the input string to an integer, or `NaN` if the input is not an integer.
*
* @default true
* @param [radix=10] - radix or base (defaults to 10)
*/
outlookdotcom_remove_subaddress?: boolean;
function toInt(input: string, radix?: number): number;
/**
* Yahoo Mail addresses are known to be case-insensitive, so this switch allows lowercasing them even when `all_lowercase` is set to `false`.
* Please note that when `all_lowercase` is `true`, Yahoo Mail addresses are lowercased regardless of the value of this setting.
* Trim characters from both sides of the input.
*
* @default true
* @param [chars] - characters (defaults to whitespace)
*/
yahoo_lowercase?: boolean;
function trim(input: string, chars?: string): string;
/**
* Normalizes addresses by removing "sub-addresses", which is the part following a `"-"` sign
* (e.g. `"foo-bar@yahoo.com"` becomes `"foo@yahoo.com"`).
* Remove characters that do not appear in the whitelist.
*
* @default true
* @param chars - The characters are used in a `RegExp` and so you will need to escape some chars, e.g. `whitelist(input, '\\[\\]')`.
*/
yahoo_remove_subaddress?: boolean;
function whitelist(input: string, chars: string): string;
/**
* iCloud addresses (including MobileMe) are known to be case-insensitive, so this switch allows lowercasing them even when `all_lowercase` is set to `false`.
* Please note that when `all_lowercase` is `true`, iCloud addresses are lowercased regardless of the value of this setting.
*
* @default true
* Converts to string.
*/
icloud_lowercase?: boolean;
/**
* Normalizes addresses by removing "sub-addresses", which is the part following a `"+"` sign
* (e.g. `"foo+bar@icloud.com"` becomes `"foo@icloud.com"`).
*
* @default true
*/
icloud_remove_subaddress?: boolean;
function toString(input: any): string;
}
/**
* Canonicalizes an email address. (This doesn't validate that the input is an email, if you want to validate the email use `isEmail` beforehand)
*
* @param [options] - Options
*/
export function normalizeEmail(email: string, options?: NormalizeEmailOptions): string | false;
/**
* Trim characters from the right-side of the input.
*
* @param [chars] - characters (defaults to whitespace)
*/
export function rtrim(input: string, chars?: string): string;
/**
* Remove characters with a numerical value < `32` and `127`, mostly control characters.
* Unicode-safe in JavaScript.
*
* @param [keep_new_lines=false] - if `true`, newline characters are preserved (`\n` and `\r`, hex `0xA` and `0xD`).
*/
export function stripLow(input: string, keep_new_lines?: boolean): string;
/**
* Convert the input string to a boolean.
* Everything except for `'0'`, `'false'` and `''` returns `true`.
*
* @param [strict=false] - in `strict` mode, only `'1'` and `'true'` return `true`.
*/
export function toBoolean(input: string, strict?: boolean): boolean;
/**
* Convert the input string to a `Date`, or `null` if the input is not a date.
*/
export function toDate(input: string): Date | null;
/**
* Convert the input string to a float, or `NaN` if the input is not a float.
*/
export function toFloat(input: string): number;
/**
* Convert the input string to an integer, or `NaN` if the input is not an integer.
*
* @param [radix=10] - radix or base (defaults to 10)
*/
export function toInt(input: string, radix?: number): number;
/**
* Trim characters from both sides of the input.
*
* @param [chars] - characters (defaults to whitespace)
*/
export function trim(input: string, chars?: string): string;
/**
* Remove characters that do not appear in the whitelist.
*
* @param chars - The characters are used in a `RegExp` and so you will need to escape some chars, e.g. `whitelist(input, '\\[\\]')`.
*/
export function whitelist(input: string, chars: string): string;
/**
* Converts to string.
*/
export function toString(input: any): string;
import * as Validator from './';
export default Validator;
export default validator;

@@ -1,1 +0,2 @@

export { blacklist as default } from '../';
import validator from '../';
export default validator.blacklist;

@@ -1,1 +0,2 @@

export { contains as default } from '../';
import validator from '../';
export default validator.contains;

@@ -1,1 +0,2 @@

export { equals as default } from '../';
import validator from '../';
export default validator.equals;

@@ -1,1 +0,2 @@

export { escape as default } from '../';
import validator from '../';
export default validator.escape;

@@ -1,1 +0,2 @@

export { isAfter as default } from '../';
import validator from '../';
export default validator.isAfter;

@@ -1,1 +0,2 @@

export { isAlpha as default } from '../';
import validator from '../';
export default validator.isAlpha;

@@ -1,1 +0,2 @@

export { isAlphanumeric as default } from '../';
import validator from '../';
export default validator.isAlphanumeric;

@@ -1,1 +0,2 @@

export { isAscii as default } from '../';
import validator from '../';
export default validator.isAscii;

@@ -1,1 +0,2 @@

export { isBase32 as default } from '..';
import validator from '../';
export default validator.isBase32;

@@ -1,1 +0,2 @@

export { isBase64 as default } from '../';
import validator from '../';
export default validator.isBase64;

@@ -1,1 +0,2 @@

export { isBefore as default } from '../';
import validator from '../';
export default validator.isBefore;

@@ -1,1 +0,2 @@

export { isBIC as default } from '../';
import validator from '../';
export default validator.isBIC;

@@ -1,1 +0,2 @@

export { isBoolean as default } from '../';
import validator from '../';
export default validator.isBoolean;

@@ -1,1 +0,2 @@

export { isByteLength as default } from '../';
import validator from '../';
export default validator.isByteLength;

@@ -1,1 +0,2 @@

export { isCreditCard as default } from '../';
import validator from '../';
export default validator.isCreditCard;

@@ -1,1 +0,2 @@

export { isCurrency as default } from '../';
import validator from '../';
export default validator.isCurrency;

@@ -1,1 +0,2 @@

export { isDataURI as default } from '../';
import validator from '../';
export default validator.isDataURI;

@@ -1,1 +0,2 @@

export { isDecimal as default } from '../';
import validator from '../';
export default validator.isDecimal;

@@ -1,1 +0,2 @@

export { isDivisibleBy as default } from '../';
import validator from '../';
export default validator.isDivisibleBy;

@@ -1,1 +0,2 @@

export { isEmail as default } from '../';
import validator from '../';
export default validator.isEmail;

@@ -1,1 +0,2 @@

export { isEmpty as default } from '../';
import validator from '../';
export default validator.isEmpty;

@@ -1,1 +0,2 @@

export { isFloat as default } from '../';
import validator from '../';
export default validator.isFloat;

@@ -1,1 +0,2 @@

export { isFQDN as default } from '../';
import validator from '../';
export default validator.isFQDN;

@@ -1,1 +0,2 @@

export { isFullWidth as default } from '../';
import validator from '../';
export default validator.isFullWidth;

@@ -1,1 +0,2 @@

export { isHalfWidth as default } from '../';
import validator from '../';
export default validator.isHalfWidth;

@@ -1,1 +0,2 @@

export { isHash as default } from '../';
import validator from '../';
export default validator.isHash;

@@ -1,1 +0,2 @@

export { isHexadecimal as default } from '../';
import validator from '../';
export default validator.isHexadecimal;

@@ -1,1 +0,2 @@

export { isHexColor as default } from '../';
import validator from '../';
export default validator.isHexColor;

@@ -1,1 +0,2 @@

export { isIdentityCard as default } from '..';
import validator from '../';
export default validator.isIdentityCard;

@@ -1,1 +0,2 @@

export { isIn as default } from '../';
import validator from '../';
export default validator.isIn;

@@ -1,1 +0,2 @@

export { isInt as default } from '../';
import validator from '../';
export default validator.isInt;

@@ -1,1 +0,2 @@

export { isIP as default } from '../';
import validator from '../';
export default validator.isIP;

@@ -1,1 +0,2 @@

export { isIPRange as default } from '..';
import validator from '../';
export default validator.isIPRange;

@@ -1,1 +0,2 @@

export { isISBN as default } from '../';
import validator from '../';
export default validator.isISBN;

@@ -1,1 +0,2 @@

export { isISIN as default } from '../';
import validator from '../';
export default validator.isISIN;

@@ -1,1 +0,2 @@

export { isISO31661Alpha2 as default } from '../';
import validator from '../';
export default validator.isISO31661Alpha2;

@@ -1,1 +0,2 @@

export { isISO31661Alpha3 as default } from '../';
import validator from '../';
export default validator.isISO31661Alpha3;

@@ -1,1 +0,2 @@

export { isISO8601 as default } from '../';
import validator from '../';
export default validator.isISO8601;

@@ -1,1 +0,2 @@

export { isISRC as default } from '../';
import validator from '../';
export default validator.isISRC;

@@ -1,1 +0,2 @@

export { isISSN as default } from '../';
import validator from '../';
export default validator.isISSN;

@@ -1,1 +0,2 @@

export { isJSON as default } from '../';
import validator from '../';
export default validator.isJSON;

@@ -1,1 +0,2 @@

export { isJWT as default } from '../';
import validator from '../';
export default validator.isJWT;

@@ -1,1 +0,2 @@

export { isLatLong as default } from '../';
import validator from '../';
export default validator.isLatLong;

@@ -1,1 +0,2 @@

export { isLength as default } from '../';
import validator from '../';
export default validator.isLength;

@@ -1,1 +0,2 @@

export { isLowercase as default } from '../';
import validator from '../';
export default validator.isLowercase;

@@ -1,1 +0,2 @@

export { isMACAddress as default } from '../';
import validator from '../';
export default validator.isMACAddress;

@@ -1,1 +0,2 @@

export { isMagnetURI as default } from '..';
import validator from '../';
export default validator.isMagnetURI;

@@ -1,1 +0,2 @@

export { isMD5 as default } from '../';
import validator from '../';
export default validator.isMD5;

@@ -1,1 +0,2 @@

export { isMimeType as default } from '../';
import validator from '../';
export default validator.isMimeType;

@@ -1,1 +0,2 @@

export { isMobilePhone as default } from '../';
import validator from '../';
export default validator.isMobilePhone;

@@ -1,1 +0,2 @@

export { isMongoId as default } from '../';
import validator from '../';
export default validator.isMongoId;

@@ -1,1 +0,2 @@

export { isMultibyte as default } from '../';
import validator from '../';
export default validator.isMultibyte;

@@ -1,1 +0,2 @@

export { isNumeric as default } from '../';
import validator from '../';
export default validator.isNumeric;

@@ -1,1 +0,2 @@

export { isOctal as default } from '..';
import validator from '../';
export default validator.isOctal;

@@ -1,1 +0,2 @@

export { isPort as default } from '../';
import validator from '../';
export default validator.isPort;

@@ -1,1 +0,2 @@

export { isPostalCode as default } from '../';
import validator from '../';
export default validator.isPostalCode;

@@ -1,1 +0,2 @@

export { isRFC3339 as default } from '../';
import validator from '../';
export default validator.isRFC3339;

@@ -1,1 +0,2 @@

export { isSlug as default } from '..';
import validator from '../';
export default validator.isSlug;

@@ -1,1 +0,2 @@

export { isSurrogatePair as default } from '../';
import validator from '../';
export default validator.isSurrogatePair;

@@ -1,1 +0,2 @@

export { isUppercase as default } from '../';
import validator from '../';
export default validator.isUppercase;

@@ -1,1 +0,2 @@

export { isURL as default } from '../';
import validator from '../';
export default validator.isURL;

@@ -1,1 +0,2 @@

export { isUUID as default } from '../';
import validator from '../';
export default validator.isUUID;

@@ -1,1 +0,2 @@

export { isVariableWidth as default } from '../';
import validator from '../';
export default validator.isVariableWidth;

@@ -1,1 +0,2 @@

export { isWhitelisted as default } from '../';
import validator from '../';
export default validator.isWhitelisted;

@@ -1,1 +0,2 @@

export { ltrim as default } from '../';
import validator from '../';
export default validator.ltrim;

@@ -1,1 +0,2 @@

export { matches as default } from '../';
import validator from '../';
export default validator.matches;

@@ -1,1 +0,2 @@

export { normalizeEmail as default } from '../';
import validator from '../';
export default validator.normalizeEmail;

@@ -1,1 +0,2 @@

export { rtrim as default } from '../';
import validator from '../';
export default validator.rtrim;

@@ -1,1 +0,2 @@

export { stripLow as default } from '../';
import validator from '../';
export default validator.stripLow;

@@ -1,1 +0,2 @@

export { toBoolean as default } from '../';
import validator from '../';
export default validator.toBoolean;

@@ -1,1 +0,2 @@

export { toDate as default } from '../';
import validator from '../';
export default validator.toDate;

@@ -1,1 +0,2 @@

export { toFloat as default } from '../';
import validator from '../';
export default validator.toFloat;

@@ -1,1 +0,2 @@

export { toInt as default } from '../';
import validator from '../';
export default validator.toInt;

@@ -1,1 +0,2 @@

export { trim as default } from '../';
import validator from '../';
export default validator.trim;

@@ -1,1 +0,2 @@

export { unescape as default } from '../';
import validator from '../';
export default validator.unescape;

@@ -1,1 +0,2 @@

export { whitelist as default } from '../';
import validator from '../';
export default validator.whitelist;
{
"name": "@types/validator",
"version": "12.0.0",
"version": "12.0.1",
"description": "TypeScript definitions for validator.js",

@@ -23,3 +23,3 @@ "license": "MIT",

{
"name": "Louy Alakkad",
"name": "Louay Alakkad",
"url": "https://github.com/louy",

@@ -68,4 +68,4 @@ "githubUsername": "louy"

"dependencies": {},
"typesPublisherContentHash": "0cc6239c47020475e5d0091cacbe72bd1014ec76e6a4b8811e64ae0e62188beb",
"typesPublisherContentHash": "12107961dad1214dbf82eb5432aa655cfa756ceee20d82f93ae05b5cb3999f77",
"typeScriptVersion": "2.8"
}

@@ -11,3 +11,3 @@ # Installation

### Additional Details
* Last updated: Mon, 18 Nov 2019 20:48:16 GMT
* Last updated: Mon, 25 Nov 2019 22:05:22 GMT
* Dependencies: none

@@ -17,2 +17,2 @@ * Global values: none

# Credits
These definitions were written by tgfjt (https://github.com/tgfjt), Ilya Mochalov (https://github.com/chrootsu), Ayman Nedjmeddine (https://github.com/IOAyman), Louy Alakkad (https://github.com/louy), Kacper Polak (https://github.com/kacepe), Bonggyun Lee (https://github.com/deptno), Naoto Yokoyama (https://github.com/builtinnya), Philipp Katz (https://github.com/qqilihq), Jace Warren (https://github.com/keatz55), and Munif Tanjim (https://github.com/MunifTanjim).
These definitions were written by tgfjt (https://github.com/tgfjt), Ilya Mochalov (https://github.com/chrootsu), Ayman Nedjmeddine (https://github.com/IOAyman), Louay Alakkad (https://github.com/louy), Kacper Polak (https://github.com/kacepe), Bonggyun Lee (https://github.com/deptno), Naoto Yokoyama (https://github.com/builtinnya), Philipp Katz (https://github.com/qqilihq), Jace Warren (https://github.com/keatz55), and Munif Tanjim (https://github.com/MunifTanjim).
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc