Skip to main content
Latest
File
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358
// Type definitions for validator.js 13.1// Project: https://github.com/validatorjs/validator.js// Definitions 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>// Munif Tanjim <https://github.com/MunifTanjim>// Vlad Poluch <https://github.com/vlapo>// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped// TypeScript Version: 2.1
declare namespace validator { const version: string;

/****************** *** Validators *** ******************/
/** * 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 */ 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) */ function isAfter(str: string, date?: string): boolean;
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';
const isAlphaLocales: AlphaLocale[];
/** * Check if the string contains only letters (a-zA-Z). * * @param [locale] - AlphaLocale */ function isAlpha(str: string, locale?: AlphaLocale): 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';
const isAlphanumericLocales: AlphanumericLocale[];
/** * Check if the string contains only letters and numbers. * * @param [locale] - AlphanumericLocale */ function isAlphanumeric(str: string, locale?: AlphanumericLocale): boolean;
/** * Check if the string contains ASCII chars only. */ function isAscii(str: string): boolean;
/** * Check if a string is base32 encoded. */ function isBase32(str: string): boolean;
interface IsBase64Options { /** * @default false */ urlSafe?: boolean; }
/** * Check if a string is base64 encoded. * * @param [options] - Options */ function isBase64(str: string, options?: IsBase64Options): boolean;
/** * Check if the string is a date that's before the specified date. * * @param [date] - Date string (defaults to now) */ function isBefore(str: string, date?: string): boolean;
/** * Check if a string is a IBAN (International Bank Account Number). */ function isIBAN(str: string): boolean;
/** * Check if a string is a BIC (Bank Identification Code) or SWIFT code. */ function isBIC(str: string): boolean;
/** * check if a string is a boolean. */ function isBoolean(str: string): boolean;
interface IsByteLengthOptions { /** * @default 0 */ min?: number; /** * @default undefined */ max?: number; }
/** * Check if the string's length (in UTF-8 bytes) falls in a range. * * @param [options] - Options */ function isByteLength(str: string, options?: IsByteLengthOptions): boolean;
/** * Check if the string is a credit card. */ 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; }
/** * Check if the string is a valid currency amount. * * @param [options] - Options */ function isCurrency(str: string, options?: IsCurrencyOptions): boolean;
/** * Check if the string is an [Ethereum](https://ethereum.org/) address using basic regex. Does not validate address checksums. */ function isEthereumAddress(str: string): boolean;
/** * Check if the string is a valid BTC address. */ function isBtcAddress(str: string): boolean;
/** * Check if the string is a [data uri format](https://developer.mozilla.org/en-US/docs/Web/HTTP/data_URIs). */ function isDataURI(str: string): boolean;
interface IsDateOptions { /** * @default false */ format?: string; /** * If strictMode is set to true, * the validator will reject inputs different from format. * * @default false */ strictMode?: boolean; /** * `delimiters` is an array of allowed date delimiters * * @default ['/', '-'] */ delimiters?: string[]; }
/** * Check if the string is a valid date. */ function isDate(str: string, options?: IsDateOptions): 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; }
/** * Check if the string represents a decimal number, * such as `0.1`, `.3`, `1.1`, `1.00003`, `4.0` etc. * * @param [options] - Options */ function isDecimal(str: string, options?: IsDecimalOptions): boolean;
/** * Check if the string is a number that's divisible by another. * * @param number - Divider number */ 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; }
/** * Check if the string is an email. * * @param [options] - Options */ function isEmail(str: string, options?: IsEmailOptions): boolean;
interface IsEmptyOptions { /** * @default false */ ignore_whitespace?: boolean; }
/** * Check if the string has a length of zero. * * @param [options] - Options */ function isEmpty(str: string, options?: IsEmptyOptions): 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';
const isFloatLocales: FloatLocale[];
interface IsFloatOptions { /** * less or equal */ min?: number; /** * greater or equal */ max?: number; /** * greater than */ gt?: number; /** * less than */ lt?: number; /** * FloatLocale */ locale?: FloatLocale; }
/** * Check if the string is a float. * * @param [options] - Options */ 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; }
/** * Check if the string is a fully qualified domain name (e.g. `domain.com`). * * @param [options] - Options */ function isFQDN(str: string, options?: IsFQDNOptions): boolean;
/** * Check if the string contains any full-width chars. */ function isFullWidth(str: string): boolean;
/** * Check if the string contains any half-width chars. */ function isHalfWidth(str: string): boolean;
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 */ function isHash(str: string, algorithm: HashAlgorithm): boolean;
/** * Check if the string is a hexadecimal number. */ function isHexadecimal(str: string): boolean;
/** * Check if the string is a hexadecimal color. */ function isHexColor(str: string): boolean;
/** * Check if the string is an HSL (hue, saturation, lightness, optional alpha) color based on CSS Colors Level 4 specification. * Comma-separated format supported. Space-separated format supported with the exception of a few edge cases (ex: hsl(200grad+.1%62%/1)). */ function isHSL(str: string): boolean;
/** * Check if the string is a rgb or rgba color. * * @param [includePercentValues=true] - If you don't want to allow to set rgb or rgba values with percents, like rgb(5%,5%,5%), or rgba(90%,90%,90%,.3), then set it to false. (defaults to true) */ function isRgbColor(str: string, includePercentValues?: boolean): boolean;
type IdentityCardLocale = 'ES' | 'he-IL' | 'zh-TW';
/** * Check if the string is a valid identity card code. * * @param [locale="any"] - IdentityCardLocale */ function isIdentityCard(str: string, locale?: 'any' | IdentityCardLocale): boolean;
/** * Check if the string is in a array of allowed values. * * @param values - Allowed values. */ 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; }
/** * Check if the string is an integer. * * @param [options] - Options */ function isInt(str: string, options?: IsIntOptions): boolean;
type IPVersion = '4' | '6' | 4 | 6;
/** * Check if the string is an IP (version 4 or 6). * * @param [version] - IP Version */ function isIP(str: string, version?: IPVersion): boolean;
/** * Check if the string is an IP Range (version 4 only). */ function isIPRange(str: string): boolean;
type ISBNVersion = '10' | '13' | 10 | 13;
/** * Check if the string is an ISBN (version 10 or 13). * * @param [version] - ISBN Version */ function isISBN(str: string, version?: ISBNVersion): boolean;
/** * Check if the string is an EAN (European Article Number). */ function isEAN(str: string): boolean;
/** * Check if the string is an [ISIN](https://en.wikipedia.org/wiki/International_Securities_Identification_Number) (stock/security identifier). */ 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. */ 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. */ 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; }
/** * Check if the string is a valid [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) date. * * @param [options] - Options */ function isISO8601(str: string, options?: IsISO8601Options): 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; }
/** * Check if the string is an [ISSN](https://en.wikipedia.org/wiki/International_Standard_Serial_Number). * * @param [options] - Options */ function isISSN(str: string, options?: IsISSNOptions): boolean;
/** * Check if the string is a [ISRC](https://en.wikipedia.org/wiki/International_Standard_Recording_Code). */ function isISRC(str: string): boolean;
/** * Check if the string is a valid [RFC 3339](https://tools.ietf.org/html/rfc3339) date. */ function isRFC3339(str: string): boolean;
/** * Check if the string is valid JSON (note: uses `JSON.parse`). */ function isJSON(str: string): boolean;
/** * Check if the string is valid JWT token. */ function isJWT(str: string): boolean;
/** * Check if the string is a valid latitude-longitude coordinate in the format: * * `lat,long` or `lat, long`. */ function isLatLong(str: string): boolean;
interface IsLengthOptions { /** * @default 0 */ min?: number; /** * @default undefined */ max?: number; }
/** * Check if the string's length falls in a range. * * Note: this function takes into account surrogate pairs. * * @param [options] - Options */ function isLength(str: string, options?: IsLengthOptions): boolean;
/** * Check if the string is a locale. */ function isLocale(str: string): boolean;
/** * Check if the string is lowercase. */ function isLowercase(str: string): 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 a MAC address. * * @param [options] - Options */ function isMACAddress(str: string, options?: IsMACAddressOptions): boolean;
/** * Check if the string is a [magnet uri format](https://en.wikipedia.org/wiki/Magnet_URI_scheme). */ function isMagnetURI(str: string): boolean;
/** * Check if the string is a MD5 hash. */ function isMD5(str: string): boolean;
/** * Check if the string matches to a valid [MIME type](https://en.wikipedia.org/wiki/Media_type) format. */ function isMimeType(str: string): 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';
const isMobilePhoneLocales: MobilePhoneLocale[];
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 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 a valid hex-encoded representation of a [MongoDB ObjectId](http://docs.mongodb.org/manual/reference/object-id/). */ function isMongoId(str: string): boolean;
/** * Check if the string contains one or more multibyte chars. */ function isMultibyte(str: string): 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 contains only numbers. * * @param [options] - Options */ function isNumeric(str: string, options?: IsNumericOptions): boolean;
/** * Check if the string is a valid octal number. */ function isOctal(str: string): boolean;
/** * Check if the string is a valid passport number relative to a specific country code. * * @param [countryCode] - Country code */ function isPassportNumber(str: string, countryCode?: string): boolean;
/** * Check if the string is a valid port number. */ function isPort(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';
const isPostalCodeLocales: PostalCodeLocale[];
/** * Check if the string is a postal code * * @param locale - PostalCodeLocale */ function isPostalCode(str: string, locale: 'any' | PostalCodeLocale): boolean;
/** * Check if the string is a Semantic Versioning Specification (SemVer). */ function isSemVer(str: string): boolean;
/** * Check if string is considered a strong password. Allows options to be added */
interface strongPasswordOptions { minLength?: number; minLowercase?: number; minUppercase?: number; minNumbers?: number; minSymbols?: number; returnScore?: boolean; pointsPerUnique?: number; pointsPerRepeat?: number; pointsForContainingLower?: number; pointsForContainingUpper?: number; pointsForContainingNumber?: number; pointsForContainingSymbol?: number; } function isStrongPassword(str: string, options?: strongPasswordOptions): boolean; /** * Check if the string contains any surrogate pairs chars. */ function isSurrogatePair(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 is an URL. * * @param [options] - Options */ function isURL(str: string, options?: IsURLOptions): boolean;
/** * Check if the string is uppercase. */ function isUppercase(str: string): boolean;
type UUIDVersion = 3 | 4 | 5 | '3' | '4' | '5' | 'all'; /** * Check if the string is a UUID (version 3, 4 or 5). * * @param [version="all"] - UUID version */ function isUUID(str: string, version?: UUIDVersion): boolean;
/** * Check if the string contains a mixture of full and half-width chars. */ function isVariableWidth(str: string): boolean;
/** * Checks characters if they appear in the whitelist. * * @param chars - whitelist */ function isWhitelisted(str: string, chars: string | string[]): boolean;
/** * Check if string matches the pattern. * * @param pattern - `/foo/i` */ function matches(str: string, pattern: RegExp): boolean; /** * Check if string matches the pattern. * * @param pattern - `'foo'` * @param [modifiers] - `'i'` */ function matches(str: string, pattern: string, modifiers?: string): boolean;
/** * Check if the string is of type slug. */ 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, '\\[\\]')`. */ function blacklist(input: string, chars: string): string;
/** * Replace `<`, `>`, `&`, `'`, `"` and `/` with HTML entities. */ function escape(input: string): string;
/** * Replaces HTML encoded entities with `<`, `>`, `&`, `'`, `"` and `/`. */ function unescape(input: string): string;
/** * Trim characters from the left-side of the input. * * @param [chars] - characters (defaults to whitespace) */ function ltrim(input: string, chars?: string): string;
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; }
/** * 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 */ function normalizeEmail(email: string, options?: NormalizeEmailOptions): string | false;
/** * Trim characters from the right-side of the input. * * @param [chars] - characters (defaults to whitespace) */ 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`). */ 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`. */ function toBoolean(input: string, strict?: boolean): boolean;
/** * Convert the input string to a `Date`, or `null` if the input is not a date. */ function toDate(input: string): Date | null;
/** * Convert the input string to a float, or `NaN` if the input is not a float. */ 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) */ function toInt(input: string, radix?: number): number;
/** * Trim characters from both sides of the input. * * @param [chars] - characters (defaults to whitespace) */ 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, '\\[\\]')`. */ function whitelist(input: string, chars: string): string;
/** * Converts to string. */ function toString(input: any): string;}