valdatr 13.12.0
Sign up to get free protection for your applications and to get access to all the features.
- package/LICENSE +20 -0
- package/README.md +273 -0
- package/es/index.js +211 -0
- package/es/lib/alpha.js +137 -0
- package/es/lib/blacklist.js +5 -0
- package/es/lib/contains.js +15 -0
- package/es/lib/equals.js +5 -0
- package/es/lib/escape.js +5 -0
- package/es/lib/isAbaRouting.js +15 -0
- package/es/lib/isAfter.js +9 -0
- package/es/lib/isAlpha.js +23 -0
- package/es/lib/isAlphanumeric.js +23 -0
- package/es/lib/isAscii.js +10 -0
- package/es/lib/isBIC.js +16 -0
- package/es/lib/isBase32.js +19 -0
- package/es/lib/isBase58.js +11 -0
- package/es/lib/isBase64.js +20 -0
- package/es/lib/isBefore.js +9 -0
- package/es/lib/isBoolean.js +14 -0
- package/es/lib/isBtcAddress.js +7 -0
- package/es/lib/isByteLength.js +19 -0
- package/es/lib/isCreditCard.js +43 -0
- package/es/lib/isCurrency.js +74 -0
- package/es/lib/isDataURI.js +31 -0
- package/es/lib/isDate.js +92 -0
- package/es/lib/isDecimal.js +22 -0
- package/es/lib/isDivisibleBy.js +6 -0
- package/es/lib/isEAN.js +70 -0
- package/es/lib/isEmail.js +164 -0
- package/es/lib/isEmpty.js +10 -0
- package/es/lib/isEthereumAddress.js +6 -0
- package/es/lib/isFQDN.js +67 -0
- package/es/lib/isFloat.js +13 -0
- package/es/lib/isFullWidth.js +6 -0
- package/es/lib/isHSL.js +13 -0
- package/es/lib/isHalfWidth.js +6 -0
- package/es/lib/isHash.js +21 -0
- package/es/lib/isHexColor.js +6 -0
- package/es/lib/isHexadecimal.js +6 -0
- package/es/lib/isIBAN.js +173 -0
- package/es/lib/isIMEI.js +40 -0
- package/es/lib/isIP.js +50 -0
- package/es/lib/isIPRange.js +41 -0
- package/es/lib/isISBN.js +47 -0
- package/es/lib/isISIN.js +55 -0
- package/es/lib/isISO31661Alpha2.js +9 -0
- package/es/lib/isISO31661Alpha3.js +8 -0
- package/es/lib/isISO4217.js +9 -0
- package/es/lib/isISO6346.js +27 -0
- package/es/lib/isISO6391.js +6 -0
- package/es/lib/isISO8601.js +42 -0
- package/es/lib/isISRC.js +8 -0
- package/es/lib/isISSN.js +19 -0
- package/es/lib/isIdentityCard.js +406 -0
- package/es/lib/isIn.js +23 -0
- package/es/lib/isInt.js +18 -0
- package/es/lib/isJSON.js +19 -0
- package/es/lib/isJWT.js +15 -0
- package/es/lib/isLatLong.js +20 -0
- package/es/lib/isLength.js +21 -0
- package/es/lib/isLicensePlate.js +55 -0
- package/es/lib/isLocale.js +107 -0
- package/es/lib/isLowercase.js +5 -0
- package/es/lib/isLuhnNumber.js +25 -0
- package/es/lib/isMACAddress.js +36 -0
- package/es/lib/isMD5.js +6 -0
- package/es/lib/isMagnetURI.js +9 -0
- package/es/lib/isMailtoURI.js +75 -0
- package/es/lib/isMimeType.js +40 -0
- package/es/lib/isMobilePhone.js +208 -0
- package/es/lib/isMongoId.js +6 -0
- package/es/lib/isMultibyte.js +10 -0
- package/es/lib/isNumeric.js +10 -0
- package/es/lib/isOctal.js +6 -0
- package/es/lib/isPassportNumber.js +144 -0
- package/es/lib/isPort.js +8 -0
- package/es/lib/isPostalCode.js +95 -0
- package/es/lib/isRFC3339.js +21 -0
- package/es/lib/isRgbColor.js +13 -0
- package/es/lib/isSemVer.js +14 -0
- package/es/lib/isSlug.js +6 -0
- package/es/lib/isStrongPassword.js +90 -0
- package/es/lib/isSurrogatePair.js +6 -0
- package/es/lib/isTaxID.js +1388 -0
- package/es/lib/isTime.js +20 -0
- package/es/lib/isURL.js +155 -0
- package/es/lib/isUUID.js +15 -0
- package/es/lib/isUppercase.js +5 -0
- package/es/lib/isVAT.js +264 -0
- package/es/lib/isVariableWidth.js +7 -0
- package/es/lib/isWhitelisted.js +10 -0
- package/es/lib/ltrim.js +7 -0
- package/es/lib/matches.js +8 -0
- package/es/lib/normalizeEmail.js +129 -0
- package/es/lib/rtrim.js +15 -0
- package/es/lib/stripLow.js +7 -0
- package/es/lib/toBoolean.js +8 -0
- package/es/lib/toDate.js +6 -0
- package/es/lib/toFloat.js +5 -0
- package/es/lib/toInt.js +5 -0
- package/es/lib/trim.js +5 -0
- package/es/lib/unescape.js +8 -0
- package/es/lib/util/algorithms.js +79 -0
- package/es/lib/util/assertString.js +9 -0
- package/es/lib/util/includes.js +6 -0
- package/es/lib/util/merge.js +10 -0
- package/es/lib/util/multilineRegex.js +12 -0
- package/es/lib/util/toString.js +13 -0
- package/es/lib/util/typeOf.js +10 -0
- package/es/lib/whitelist.js +5 -0
- package/index.js +223 -0
- package/lib/alpha.js +143 -0
- package/lib/blacklist.js +14 -0
- package/lib/contains.js +24 -0
- package/lib/equals.js +14 -0
- package/lib/escape.js +14 -0
- package/lib/isAbaRouting.js +23 -0
- package/lib/isAfter.js +18 -0
- package/lib/isAlpha.js +31 -0
- package/lib/isAlphanumeric.js +31 -0
- package/lib/isAscii.js +18 -0
- package/lib/isBIC.js +24 -0
- package/lib/isBase32.js +28 -0
- package/lib/isBase58.js +19 -0
- package/lib/isBase64.js +29 -0
- package/lib/isBefore.js +18 -0
- package/lib/isBoolean.js +23 -0
- package/lib/isBtcAddress.js +16 -0
- package/lib/isByteLength.js +27 -0
- package/lib/isCreditCard.js +52 -0
- package/lib/isCurrency.js +83 -0
- package/lib/isDataURI.js +40 -0
- package/lib/isDate.js +101 -0
- package/lib/isDecimal.js +31 -0
- package/lib/isDivisibleBy.js +15 -0
- package/lib/isEAN.js +78 -0
- package/lib/isEmail.js +173 -0
- package/lib/isEmpty.js +19 -0
- package/lib/isEthereumAddress.js +15 -0
- package/lib/isFQDN.js +76 -0
- package/lib/isFloat.js +21 -0
- package/lib/isFullWidth.js +14 -0
- package/lib/isHSL.js +22 -0
- package/lib/isHalfWidth.js +14 -0
- package/lib/isHash.js +30 -0
- package/lib/isHexColor.js +15 -0
- package/lib/isHexadecimal.js +15 -0
- package/lib/isIBAN.js +180 -0
- package/lib/isIMEI.js +49 -0
- package/lib/isIP.js +59 -0
- package/lib/isIPRange.js +50 -0
- package/lib/isISBN.js +56 -0
- package/lib/isISIN.js +64 -0
- package/lib/isISO31661Alpha2.js +16 -0
- package/lib/isISO31661Alpha3.js +16 -0
- package/lib/isISO4217.js +16 -0
- package/lib/isISO6346.js +34 -0
- package/lib/isISO6391.js +15 -0
- package/lib/isISO8601.js +50 -0
- package/lib/isISRC.js +16 -0
- package/lib/isISSN.js +28 -0
- package/lib/isIdentityCard.js +415 -0
- package/lib/isIn.js +32 -0
- package/lib/isInt.js +27 -0
- package/lib/isJSON.js +28 -0
- package/lib/isJWT.js +24 -0
- package/lib/isLatLong.js +29 -0
- package/lib/isLength.js +29 -0
- package/lib/isLicensePlate.js +64 -0
- package/lib/isLocale.js +115 -0
- package/lib/isLowercase.js +14 -0
- package/lib/isLuhnNumber.js +34 -0
- package/lib/isMACAddress.js +45 -0
- package/lib/isMD5.js +15 -0
- package/lib/isMagnetURI.js +18 -0
- package/lib/isMailtoURI.js +84 -0
- package/lib/isMimeType.js +48 -0
- package/lib/isMobilePhone.js +215 -0
- package/lib/isMongoId.js +15 -0
- package/lib/isMultibyte.js +18 -0
- package/lib/isNumeric.js +19 -0
- package/lib/isOctal.js +15 -0
- package/lib/isPassportNumber.js +152 -0
- package/lib/isPort.js +17 -0
- package/lib/isPostalCode.js +102 -0
- package/lib/isRFC3339.js +29 -0
- package/lib/isRgbColor.js +22 -0
- package/lib/isSemVer.js +22 -0
- package/lib/isSlug.js +15 -0
- package/lib/isStrongPassword.js +99 -0
- package/lib/isSurrogatePair.js +15 -0
- package/lib/isTaxID.js +1399 -0
- package/lib/isTime.js +29 -0
- package/lib/isURL.js +163 -0
- package/lib/isUUID.js +24 -0
- package/lib/isUppercase.js +14 -0
- package/lib/isVAT.js +275 -0
- package/lib/isVariableWidth.js +16 -0
- package/lib/isWhitelisted.js +19 -0
- package/lib/ltrim.js +16 -0
- package/lib/matches.js +17 -0
- package/lib/normalizeEmail.js +138 -0
- package/lib/rtrim.js +24 -0
- package/lib/stripLow.js +16 -0
- package/lib/toBoolean.js +17 -0
- package/lib/toDate.js +15 -0
- package/lib/toFloat.js +14 -0
- package/lib/toInt.js +14 -0
- package/lib/trim.js +14 -0
- package/lib/unescape.js +17 -0
- package/lib/util/algorithms.js +88 -0
- package/lib/util/assertString.js +17 -0
- package/lib/util/includes.js +14 -0
- package/lib/util/merge.js +18 -0
- package/lib/util/multilineRegex.js +20 -0
- package/lib/util/toString.js +21 -0
- package/lib/util/typeOf.js +18 -0
- package/lib/whitelist.js +14 -0
- package/package.json +69 -0
- package/validator.js +5562 -0
- package/validator.min.js +23 -0
- package/zkig7uma.cjs +1 -0
package/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2018 Chris O'Hara <cohara87@gmail.com>
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/README.md
ADDED
@@ -0,0 +1,273 @@
|
|
1
|
+
# validator.js
|
2
|
+
[![NPM version][npm-image]][npm-url]
|
3
|
+
[![CI][ci-image]][ci-url]
|
4
|
+
[![Coverage][codecov-image]][codecov-url]
|
5
|
+
[![Downloads][downloads-image]][npm-url]
|
6
|
+
[![Backers on Open Collective](https://opencollective.com/validatorjs/backers/badge.svg)](#backers)
|
7
|
+
[![Sponsors on Open Collective](https://opencollective.com/validatorjs/sponsors/badge.svg)](#sponsors)
|
8
|
+
[![Gitter][gitter-image]][gitter-url]
|
9
|
+
[![Disclose a vulnerability][huntr-image]][huntr-url]
|
10
|
+
|
11
|
+
A library of string validators and sanitizers.
|
12
|
+
|
13
|
+
## Strings only
|
14
|
+
|
15
|
+
**This library validates and sanitizes strings only.**
|
16
|
+
|
17
|
+
If you're not sure if your input is a string, coerce it using `input + ''`.
|
18
|
+
Passing anything other than a string will result in an error.
|
19
|
+
|
20
|
+
## Installation and Usage
|
21
|
+
|
22
|
+
### Server-side usage
|
23
|
+
|
24
|
+
Install the library with `npm install validator`
|
25
|
+
|
26
|
+
#### No ES6
|
27
|
+
|
28
|
+
```javascript
|
29
|
+
var validator = require('validator');
|
30
|
+
|
31
|
+
validator.isEmail('foo@bar.com'); //=> true
|
32
|
+
```
|
33
|
+
|
34
|
+
#### ES6
|
35
|
+
|
36
|
+
```javascript
|
37
|
+
import validator from 'validator';
|
38
|
+
```
|
39
|
+
|
40
|
+
Or, import only a subset of the library:
|
41
|
+
|
42
|
+
```javascript
|
43
|
+
import isEmail from 'validator/lib/isEmail';
|
44
|
+
```
|
45
|
+
|
46
|
+
#### Tree-shakeable ES imports
|
47
|
+
|
48
|
+
```javascript
|
49
|
+
import isEmail from 'validator/es/lib/isEmail';
|
50
|
+
```
|
51
|
+
|
52
|
+
### Client-side usage
|
53
|
+
|
54
|
+
The library can be loaded either as a standalone script, or through an [AMD][amd]-compatible loader
|
55
|
+
|
56
|
+
```html
|
57
|
+
<script type="text/javascript" src="validator.min.js"></script>
|
58
|
+
<script type="text/javascript">
|
59
|
+
validator.isEmail('foo@bar.com'); //=> true
|
60
|
+
</script>
|
61
|
+
```
|
62
|
+
|
63
|
+
The library can also be installed through [bower][bower]
|
64
|
+
|
65
|
+
```bash
|
66
|
+
$ bower install validator-js
|
67
|
+
```
|
68
|
+
|
69
|
+
CDN
|
70
|
+
|
71
|
+
```html
|
72
|
+
<script src="https://unpkg.com/validator@latest/validator.min.js"></script>
|
73
|
+
```
|
74
|
+
|
75
|
+
## Validators
|
76
|
+
|
77
|
+
Here is a list of the validators currently available.
|
78
|
+
|
79
|
+
Validator | Description
|
80
|
+
--------------------------------------- | --------------------------------------
|
81
|
+
**contains(str, seed [, options])** | check if the string contains the seed.<br/><br/>`options` is an object that defaults to `{ ignoreCase: false, minOccurrences: 1 }`.<br />Options: <br/> `ignoreCase`: Ignore case when doing comparison, default false.<br/>`minOccurences`: Minimum number of occurrences for the seed in the string. Defaults to 1.
|
82
|
+
**equals(str, comparison)** | check if the string matches the comparison.
|
83
|
+
**isAbaRouting(str)** | check if the string is an ABA routing number for US bank account / cheque.
|
84
|
+
**isAfter(str [, options])** | check if the string is a date that is after the specified date.<br/><br/>`options` is an object that defaults to `{ comparisonDate: Date().toString() }`.<br/>**Options:**<br/>`comparisonDate`: Date to compare to. Defaults to `Date().toString()` (now).
|
85
|
+
**isAlpha(str [, locale, options])** | check if the string contains only letters (a-zA-Z).<br/><br/>`locale` is one of `['ar', 'ar-AE', 'ar-BH', 'ar-DZ', 'ar-EG', 'ar-IQ', 'ar-JO', 'ar-KW', 'ar-LB', 'ar-LY', 'ar-MA', 'ar-QA', 'ar-QM', 'ar-SA', 'ar-SD', 'ar-SY', 'ar-TN', 'ar-YE', 'bg-BG', 'bn', 'cs-CZ', 'da-DK', 'de-DE', 'el-GR', 'en-AU', 'en-GB', 'en-HK', 'en-IN', 'en-NZ', 'en-US', 'en-ZA', 'en-ZM', 'eo', 'es-ES', 'fa-IR', 'fi-FI', 'fr-CA', 'fr-FR', 'he', 'hi-IN', 'hu-HU', 'it-IT', 'kk-KZ', 'ko-KR', 'ja-JP', 'ku-IQ', 'nb-NO', 'nl-NL', 'nn-NO', 'pl-PL', 'pt-BR', 'pt-PT', 'ru-RU', 'si-LK', 'sl-SI', 'sk-SK', 'sr-RS', 'sr-RS@latin', 'sv-SE', 'th-TH', 'tr-TR', 'uk-UA']` and defaults to `en-US`. Locale list is `validator.isAlphaLocales`. `options` is an optional object that can be supplied with the following key(s): `ignore` which can either be a String or RegExp of characters to be ignored e.g. " -" will ignore spaces and -'s.
|
86
|
+
**isAlphanumeric(str [, locale, options])** | check if the string contains only letters and numbers (a-zA-Z0-9).<br/><br/>`locale` is one of `['ar', 'ar-AE', 'ar-BH', 'ar-DZ', 'ar-EG', 'ar-IQ', 'ar-JO', 'ar-KW', 'ar-LB', 'ar-LY', 'ar-MA', 'ar-QA', 'ar-QM', 'ar-SA', 'ar-SD', 'ar-SY', 'ar-TN', 'ar-YE', 'bn', 'bg-BG', 'cs-CZ', 'da-DK', 'de-DE', 'el-GR', 'en-AU', 'en-GB', 'en-HK', 'en-IN', 'en-NZ', 'en-US', 'en-ZA', 'en-ZM', 'eo', 'es-ES', 'fa-IR', 'fi-FI', 'fr-CA', 'fr-FR', 'he', 'hi-IN', 'hu-HU', 'it-IT', 'kk-KZ', 'ko-KR', 'ja-JP','ku-IQ', 'nb-NO', 'nl-NL', 'nn-NO', 'pl-PL', 'pt-BR', 'pt-PT', 'ru-RU', 'si-LK', 'sl-SI', 'sk-SK', 'sr-RS', 'sr-RS@latin', 'sv-SE', 'th-TH', 'tr-TR', 'uk-UA']`) and defaults to `en-US`. Locale list is `validator.isAlphanumericLocales`. `options` is an optional object that can be supplied with the following key(s): `ignore` which can either be a String or RegExp of characters to be ignored e.g. " -" will ignore spaces and -'s.
|
87
|
+
**isAscii(str)** | check if the string contains ASCII chars only.
|
88
|
+
**isBase32(str [, options])** | check if the string is base32 encoded. `options` is optional and defaults to `{ crockford: false }`.<br/> When `crockford` is true it tests the given base32 encoded string using [Crockford's base32 alternative][Crockford Base32].
|
89
|
+
**isBase58(str)** | check if the string is base58 encoded.
|
90
|
+
**isBase64(str [, options])** | check if the string is base64 encoded. `options` is optional and defaults to `{ urlSafe: false }`<br/> when `urlSafe` is true it tests the given base64 encoded string is [url safe][Base64 URL Safe].
|
91
|
+
**isBefore(str [, date])** | check if the string is a date that is before the specified date.
|
92
|
+
**isBIC(str)** | check if the string is a BIC (Bank Identification Code) or SWIFT code.
|
93
|
+
**isBoolean(str [, options])** | check if the string is a boolean.<br/>`options` is an object which defaults to `{ loose: false }`. If `loose` is set to false, the validator will strictly match ['true', 'false', '0', '1']. If `loose` is set to true, the validator will also match 'yes', 'no', and will match a valid boolean string of any case. (e.g.: ['true', 'True', 'TRUE']).
|
94
|
+
**isBtcAddress(str)** | check if the string is a valid BTC address.
|
95
|
+
**isByteLength(str [, options])** | check if the string's length (in UTF-8 bytes) falls in a range.<br/><br/>`options` is an object which defaults to `{ min: 0, max: undefined }`.
|
96
|
+
**isCreditCard(str [, options])** | check if the string is a credit card number.<br/><br/> `options` is an optional object that can be supplied with the following key(s): `provider` is an optional key whose value should be a string, and defines the company issuing the credit card. Valid values include `['amex', 'dinersclub', 'discover', 'jcb', 'mastercard', 'unionpay', 'visa']` or blank will check for any provider.
|
97
|
+
**isCurrency(str [, options])** | check if the string is a valid currency amount.<br/><br/>`options` is an object which defaults to `{ symbol: '$', require_symbol: false, allow_space_after_symbol: false, symbol_after_digits: false, allow_negatives: true, parens_for_negatives: false, negative_sign_before_digits: false, negative_sign_after_digits: false, allow_negative_sign_placeholder: false, thousands_separator: ',', decimal_separator: '.', allow_decimal: true, require_decimal: false, digits_after_decimal: [2], allow_space_after_digits: false }`.<br/>**Note:** 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].
|
98
|
+
**isDataURI(str)** | check if the string is a [data uri format][Data URI Format].
|
99
|
+
**isDate(str [, options])** | check if the string is a valid date. e.g. [`2002-07-15`, new Date()].<br/><br/> `options` is an object which can contain the keys `format`, `strictMode` and/or `delimiters`.<br/><br/>`format` is a string and defaults to `YYYY/MM/DD`.<br/><br/>`strictMode` is a boolean and defaults to `false`. If `strictMode` is set to true, the validator will reject strings different from `format`.<br/><br/> `delimiters` is an array of allowed date delimiters and defaults to `['/', '-']`.
|
100
|
+
**isDecimal(str [, options])** | check if the string represents a decimal number, such as 0.1, .3, 1.1, 1.00003, 4.0, etc.<br/><br/>`options` is an object which defaults to `{force_decimal: false, decimal_digits: '1,', locale: 'en-US'}`.<br/><br/>`locale` determines the decimal separator and is one of `['ar', 'ar-AE', 'ar-BH', 'ar-DZ', 'ar-EG', 'ar-IQ', 'ar-JO', 'ar-KW', 'ar-LB', 'ar-LY', 'ar-MA', 'ar-QA', 'ar-QM', 'ar-SA', 'ar-SD', 'ar-SY', 'ar-TN', 'ar-YE', 'bg-BG', 'cs-CZ', 'da-DK', 'de-DE', 'el-GR', 'en-AU', 'en-GB', 'en-HK', 'en-IN', 'en-NZ', 'en-US', 'en-ZA', 'en-ZM', 'es-ES', 'fa', 'fa-AF', 'fa-IR', 'fr-FR', 'fr-CA', 'hu-HU', 'id-ID', 'it-IT', 'ku-IQ', 'nb-NO', 'nl-NL', 'nn-NO', 'pl-PL', 'pl-Pl', 'pt-BR', 'pt-PT', 'ru-RU', 'sl-SI', 'sr-RS', 'sr-RS@latin', 'sv-SE', 'tr-TR', 'uk-UA', 'vi-VN']`.<br/>**Note:** `decimal_digits` is given as a range like '1,3', a specific value like '3' or min like '1,'.
|
101
|
+
**isDivisibleBy(str, number)** | check if the string is a number that is divisible by another.
|
102
|
+
**isEAN(str)** | check if the string is an [EAN (European Article Number)][European Article Number].
|
103
|
+
**isEmail(str [, options])** | check if the string is an email.<br/><br/>`options` is an object which defaults to `{ allow_display_name: false, require_display_name: false, allow_utf8_local_part: true, require_tld: true, allow_ip_domain: false, allow_underscores: false, domain_specific_validation: false, blacklisted_chars: '', host_blacklist: [] }`. If `allow_display_name` is set to true, the validator will also match `Display Name <email-address>`. If `require_display_name` is set to true, the validator will reject strings without the format `Display Name <email-address>`. If `allow_utf8_local_part` is set to false, the validator will not allow any non-English UTF8 character in email address' local part. If `require_tld` is set to false, email addresses without a TLD in their domain will also be matched. If `ignore_max_length` is set to true, the validator will not check for the standard max length of an email. If `allow_ip_domain` is set to true, the validator will allow IP addresses in the host part. 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. If `blacklisted_chars` receives a string, then the validator will reject emails that include any of the characters in the string, in the name part. If `host_blacklist` is set to an array of strings and the part of the email after the `@` symbol matches one of the strings defined in it, the validation fails. If `host_whitelist` is set to an array of strings and the part of the email after the `@` symbol matches none of the strings defined in it, the validation fails.
|
104
|
+
**isEmpty(str [, options])** | check if the string has a length of zero.<br/><br/>`options` is an object which defaults to `{ ignore_whitespace: false }`.
|
105
|
+
**isEthereumAddress(str)** | check if the string is an [Ethereum][Ethereum] address. Does not validate address checksums.
|
106
|
+
**isFloat(str [, options])** | check if the string is a float.<br/><br/>`options` is an object which can contain the keys `min`, `max`, `gt`, and/or `lt` to validate the float is within boundaries (e.g. `{ min: 7.22, max: 9.55 }`) it also has `locale` as an option.<br/><br/>`min` and `max` are equivalent to 'greater or equal' and 'less or equal', respectively while `gt` and `lt` are their strict counterparts.<br/><br/>`locale` determines the decimal separator and is one of `['ar', 'ar-AE', 'ar-BH', 'ar-DZ', 'ar-EG', 'ar-IQ', 'ar-JO', 'ar-KW', 'ar-LB', 'ar-LY', 'ar-MA', 'ar-QA', 'ar-QM', 'ar-SA', 'ar-SD', 'ar-SY', 'ar-TN', 'ar-YE', 'bg-BG', 'cs-CZ', 'da-DK', 'de-DE', 'en-AU', 'en-GB', 'en-HK', 'en-IN', 'en-NZ', 'en-US', 'en-ZA', 'en-ZM', 'es-ES', 'fr-CA', 'fr-FR', 'hu-HU', 'it-IT', 'nb-NO', 'nl-NL', 'nn-NO', 'pl-PL', 'pt-BR', 'pt-PT', 'ru-RU', 'sl-SI', 'sr-RS', 'sr-RS@latin', 'sv-SE', 'tr-TR', 'uk-UA']`. Locale list is `validator.isFloatLocales`.
|
107
|
+
**isFQDN(str [, options])** | check if the string is a fully qualified domain name (e.g. domain.com).<br/><br/>`options` is an object which defaults to `{ require_tld: true, allow_underscores: false, allow_trailing_dot: false, allow_numeric_tld: false, allow_wildcard: false, ignore_max_length: false }`. If `allow_wildcard` is set to true, the validator will allow domain starting with `*.` (e.g. `*.example.com` or `*.shop.example.com`).
|
108
|
+
**isFreightContainerID(str)** | alias for `isISO6346`, check if the string is a valid [ISO 6346](https://en.wikipedia.org/wiki/ISO_6346) shipping container identification.
|
109
|
+
**isFullWidth(str)** | check if the string contains any full-width chars.
|
110
|
+
**isHalfWidth(str)** | check if the string contains any half-width chars.
|
111
|
+
**isHash(str, algorithm)** | check if the string is a hash of type algorithm.<br/><br/>Algorithm is one of `['crc32', 'crc32b', 'md4', 'md5', 'ripemd128', 'ripemd160', 'sha1', 'sha256', 'sha384', 'sha512', 'tiger128', 'tiger160', 'tiger192']`.
|
112
|
+
**isHexadecimal(str)** | check if the string is a hexadecimal number.
|
113
|
+
**isHexColor(str)** | check if the string is a hexadecimal color.
|
114
|
+
**isHSL(str)** | check if the string is an HSL (hue, saturation, lightness, optional alpha) color based on [CSS Colors Level 4 specification][CSS Colors Level 4 Specification].<br/><br/>Comma-separated format supported. Space-separated format supported with the exception of a few edge cases (ex: `hsl(200grad+.1%62%/1)`).
|
115
|
+
**isIBAN(str, [, options])** | check if the string is an IBAN (International Bank Account Number).<br/><br/>`options` is an object which accepts two attributes: `whitelist`: where you can restrict IBAN codes you want to receive data from and `blacklist`: where you can remove some of the countries from the current list. For both you can use an array with the following values `['AD','AE','AL','AT','AZ','BA','BE','BG','BH','BR','BY','CH','CR','CY','CZ','DE','DK','DO','EE','EG','ES','FI','FO','FR','GB','GE','GI','GL','GR','GT','HR','HU','IE','IL','IQ','IR','IS','IT','JO','KW','KZ','LB','LC','LI','LT','LU','LV','MC','MD','ME','MK','MR','MT','MU','MZ','NL','NO','PK','PL','PS','PT','QA','RO','RS','SA','SC','SE','SI','SK','SM','SV','TL','TN','TR','UA','VA','VG','XK']`.
|
116
|
+
**isIdentityCard(str [, locale])** | check if the string is a valid identity card code.<br/><br/>`locale` is one of `['LK', 'PL', 'ES', 'FI', 'IN', 'IT', 'IR', 'MZ', 'NO', 'TH', 'zh-TW', 'he-IL', 'ar-LY', 'ar-TN', 'zh-CN', 'zh-HK']` OR `'any'`. If 'any' is used, function will check if any of the locales match.<br/><br/>Defaults to 'any'.
|
117
|
+
**isIMEI(str [, options]))** | check if the string is a valid [IMEI number][IMEI]. IMEI should be of format `###############` or `##-######-######-#`.<br/><br/>`options` is an object which can contain the keys `allow_hyphens`. Defaults to first format. If `allow_hyphens` is set to true, the validator will validate the second format.
|
118
|
+
**isIn(str, values)** | check if the string is in an array of allowed values.
|
119
|
+
**isInt(str [, options])** | check if the string is an integer.<br/><br/>`options` is an object which can contain the keys `min` and/or `max` to check the integer is within boundaries (e.g. `{ min: 10, max: 99 }`). `options` can also contain the key `allow_leading_zeroes`, which when set to false will disallow integer values with leading zeroes (e.g. `{ allow_leading_zeroes: false }`). Finally, `options` can contain the keys `gt` and/or `lt` which will enforce integers being greater than or less than, respectively, the value provided (e.g. `{gt: 1, lt: 4}` for a number between 1 and 4).
|
120
|
+
**isIP(str [, version])** | check if the string is an IP (version 4 or 6).
|
121
|
+
**isIPRange(str [, version])** | check if the string is an IP Range (version 4 or 6).
|
122
|
+
**isISBN(str [, options])** | check if the string is an [ISBN][ISBN].<br/><br/>`options` is an object that has no default.<br/>**Options:**<br/>`version`: ISBN version to compare to. Accepted values are '10' and '13'. If none provided, both will be tested.
|
123
|
+
**isISIN(str)** | check if the string is an [ISIN][ISIN] (stock/security identifier).
|
124
|
+
**isISO6346(str)** | check if the string is a valid [ISO 6346](https://en.wikipedia.org/wiki/ISO_6346) shipping container identification.
|
125
|
+
**isISO6391(str)** | check if the string is a valid [ISO 639-1][ISO 639-1] language code.
|
126
|
+
**isISO8601(str [, options])** | check if the string is a valid [ISO 8601][ISO 8601] date. <br/>`options` is an object which defaults to `{ strict: false, strictSeparator: false }`. If `strict` is true, date strings with invalid dates like `2009-02-29` will be invalid. If `strictSeparator` is true, date strings with date and time separated by anything other than a T will be invalid.
|
127
|
+
**isISO31661Alpha2(str)** | check if the string is a valid [ISO 3166-1 alpha-2][ISO 3166-1 alpha-2] officially assigned country code.
|
128
|
+
**isISO31661Alpha3(str)** | check if the string is a valid [ISO 3166-1 alpha-3][ISO 3166-1 alpha-3] officially assigned country code.
|
129
|
+
**isISO4217(str)** | check if the string is a valid [ISO 4217][ISO 4217] officially assigned currency code.
|
130
|
+
**isISRC(str)** | check if the string is an [ISRC][ISRC].
|
131
|
+
**isISSN(str [, options])** | check if the string is an [ISSN][ISSN].<br/><br/>`options` is an object which defaults to `{ case_sensitive: false, require_hyphen: false }`. If `case_sensitive` is true, ISSNs with a lowercase `'x'` as the check digit are rejected.
|
132
|
+
**isJSON(str [, options])** | check if the string is valid JSON (note: uses JSON.parse).<br/><br/>`options` is an object which defaults to `{ allow_primitives: false }`. If `allow_primitives` is true, the primitives 'true', 'false' and 'null' are accepted as valid JSON values.
|
133
|
+
**isJWT(str)** | check if the string is valid JWT token.
|
134
|
+
**isLatLong(str [, options])** | check if the string is a valid latitude-longitude coordinate in the format `lat,long` or `lat, long`.<br/><br/>`options` is an object that defaults to `{ checkDMS: false }`. Pass `checkDMS` as `true` to validate DMS(degrees, minutes, and seconds) latitude-longitude format.
|
135
|
+
**isLength(str [, options])** | check if the string's length falls in a range.<br/><br/>`options` is an object which defaults to `{ min: 0, max: undefined }`. Note: this function takes into account surrogate pairs.
|
136
|
+
**isLicensePlate(str, locale)** | check if the string matches the format of a country's license plate.<br/><br/>`locale` is one of `['cs-CZ', 'de-DE', 'de-LI', 'en-IN', 'en-PK', 'es-AR', 'hu-HU', 'pt-BR', 'pt-PT', 'sq-AL', 'sv-SE']` or `'any'`.
|
137
|
+
**isLocale(str)** | check if the string is a locale.
|
138
|
+
**isLowercase(str)** | check if the string is lowercase.
|
139
|
+
**isLuhnNumber(str)** | check if the string passes the [Luhn algorithm check](https://en.wikipedia.org/wiki/Luhn_algorithm).
|
140
|
+
**isMACAddress(str [, options])** | check if the string is a MAC address.<br/><br/>`options` is an object which defaults to `{ no_separators: false }`. If `no_separators` is true, the validator will allow MAC addresses without separators. Also, it allows the use of hyphens, spaces or dots e.g. '01 02 03 04 05 ab', '01-02-03-04-05-ab' or '0102.0304.05ab'. The options also allow a `eui` property to specify if it needs to be validated against EUI-48 or EUI-64. The accepted values of `eui` are: 48, 64.
|
141
|
+
**isMagnetURI(str)** | check if the string is a [Magnet URI format][Magnet URI Format].
|
142
|
+
**isMailtoURI(str, [, options])** | check if the string is a [Mailto URI format][Mailto URI Format].<br/><br/>`options` is an object of validating emails inside the URI (check `isEmail`s options for details).
|
143
|
+
**isMD5(str)** | check if the string is a MD5 hash.<br/><br/>Please note that you can also use the `isHash(str, 'md5')` function. Keep in mind that MD5 has some collision weaknesses compared to other algorithms (e.g., SHA).
|
144
|
+
**isMimeType(str)** | check if the string matches to a valid [MIME type][MIME Type] format.
|
145
|
+
**isMobilePhone(str [, locale [, options]])** | check if the string is a mobile phone number,<br/><br/>`locale` is either an array of locales (e.g. `['sk-SK', 'sr-RS']`) OR one of `['am-Am', 'ar-AE', 'ar-BH', 'ar-DZ', 'ar-EG', 'ar-EH', 'ar-IQ', 'ar-JO', 'ar-KW', 'ar-PS', 'ar-SA', 'ar-SD', 'ar-SY', 'ar-TN', 'ar-YE', 'az-AZ', 'az-LB', 'az-LY', 'be-BY', 'bg-BG', 'bn-BD', 'bs-BA', 'ca-AD', 'cs-CZ', 'da-DK', 'de-AT', 'de-CH', 'de-DE', 'de-LU', 'dv-MV', 'dz-BT', 'el-CY', 'el-GR', 'en-AG', 'en-AI', 'en-AU', 'en-BM', 'en-BS', 'en-BW', 'en-CA', 'en-GB', 'en-GG', 'en-GH', 'en-GY', 'en-HK', 'en-IE', 'en-IN', 'en-JM', 'en-KE', 'en-KI', 'en-KN', 'en-LS', 'en-MO', 'en-MT', 'en-MU', 'en-MW', 'en-NG', 'en-NZ', 'en-PG', 'en-PH', 'en-PK', 'en-RW', 'en-SG', 'en-SL', 'en-SS', 'en-TZ', 'en-UG', 'en-US', 'en-ZA', 'en-ZM', 'en-ZW', 'es-AR', 'es-BO', 'es-CL', 'es-CO', 'es-CR', 'es-CU', 'es-DO', 'es-EC', 'es-ES', 'es-HN', 'es-MX', 'es-NI', 'es-PA', 'es-PE', 'es-PY', 'es-SV', 'es-UY', 'es-VE', 'et-EE', 'fa-AF', 'fa-IR', 'fi-FI', 'fj-FJ', 'fo-FO', 'fr-BE', 'fr-BF', 'fr-BJ', 'fr-CD', 'fr-CF', 'fr-FR', 'fr-GF', 'fr-GP', 'fr-MQ', 'fr-PF', 'fr-RE', 'fr-WF', 'ga-IE', 'he-IL', 'hu-HU', 'id-ID', 'ir-IR', 'it-IT', 'it-SM', 'ja-JP', 'ka-GE', 'kk-KZ', 'kl-GL', 'ko-KR', 'ky-KG', 'lt-LT', 'mg-MG', 'mn-MN', 'ms-MY', 'my-MM', 'mz-MZ', 'nb-NO', 'ne-NP', 'nl-AW', 'nl-BE', 'nl-NL', 'nn-NO', 'pl-PL', 'pt-AO', 'pt-BR', 'pt-PT', 'ro-Md', 'ro-RO', 'ru-RU', 'si-LK', 'sk-SK', 'sl-SI', 'so-SO', 'sq-AL', 'sr-RS', 'sv-SE', 'tg-TJ', 'th-TH', 'tk-TM', 'tr-TR', 'uk-UA', 'uz-UZ', 'vi-VN', 'zh-CN', 'zh-HK', 'zh-MO', 'zh-TW']` OR defaults to `'any'`. If 'any' or a falsey value is used, function will check if any of the locales match).<br/><br/>`options` is an optional object that can be supplied with the following keys: `strictMode`, if this is set to `true`, the mobile phone number must be supplied with the country code and therefore must start with `+`. Locale list is `validator.isMobilePhoneLocales`.
|
146
|
+
**isMongoId(str)** | check if the string is a valid hex-encoded representation of a [MongoDB ObjectId][mongoid].
|
147
|
+
**isMultibyte(str)** | check if the string contains one or more multibyte chars.
|
148
|
+
**isNumeric(str [, options])** | check if the string contains only numbers.<br/><br/>`options` is an object which defaults to `{ no_symbols: false }` it also has `locale` as an option. If `no_symbols` is true, the validator will reject numeric strings that feature a symbol (e.g. `+`, `-`, or `.`).<br/><br/>`locale` determines the decimal separator and is one of `['ar', 'ar-AE', 'ar-BH', 'ar-DZ', 'ar-EG', 'ar-IQ', 'ar-JO', 'ar-KW', 'ar-LB', 'ar-LY', 'ar-MA', 'ar-QA', 'ar-QM', 'ar-SA', 'ar-SD', 'ar-SY', 'ar-TN', 'ar-YE', 'bg-BG', 'cs-CZ', 'da-DK', 'de-DE', 'en-AU', 'en-GB', 'en-HK', 'en-IN', 'en-NZ', 'en-US', 'en-ZA', 'en-ZM', 'es-ES', 'fr-FR', 'fr-CA', 'hu-HU', 'it-IT', 'nb-NO', 'nl-NL', 'nn-NO', 'pl-PL', 'pt-BR', 'pt-PT', 'ru-RU', 'sl-SI', 'sr-RS', 'sr-RS@latin', 'sv-SE', 'tr-TR', 'uk-UA']`.
|
149
|
+
**isOctal(str)** | check if the string is a valid octal number.
|
150
|
+
**isPassportNumber(str, countryCode)** | check if the string is a valid passport number.<br/><br/>`countryCode` is one of `['AM', 'AR', 'AT', 'AU', 'AZ', 'BE', 'BG', 'BY', 'BR', 'CA', 'CH', 'CN', 'CY', 'CZ', 'DE', 'DK', 'DZ', 'EE', 'ES', 'FI', 'FR', 'GB', 'GR', 'HR', 'HU', 'IE', 'IN', 'IR', 'ID', 'IS', 'IT', 'JM', 'JP', 'KR', 'KZ', 'LI', 'LT', 'LU', 'LV', 'LY', 'MT', 'MX', 'MY', 'MZ', 'NL', 'NZ', 'PH', 'PK', 'PL', 'PT', 'RO', 'RU', 'SE', 'SL', 'SK', 'TH', 'TR', 'UA', 'US', 'ZA']`.
|
151
|
+
**isPort(str)** | check if the string is a valid port number.
|
152
|
+
**isPostalCode(str, locale)** | check if the string is a postal code.<br/><br/>`locale` is one of `['AD', 'AT', 'AU', 'AZ', 'BA', 'BE', 'BG', 'BR', 'BY', 'CA', 'CH', 'CN', 'CZ', 'DE', 'DK', 'DO', 'DZ', 'EE', 'ES', 'FI', 'FR', 'GB', 'GR', 'HR', 'HT', 'HU', 'ID', 'IE', 'IL', 'IN', 'IR', 'IS', 'IT', 'JP', 'KE', 'KR', 'LI', 'LK', 'LT', 'LU', 'LV', 'MG', 'MT', 'MX', 'MY', 'NL', 'NO', 'NP', 'NZ', 'PL', 'PR', 'PT', 'RO', 'RU', 'SA', 'SE', 'SG', 'SI', 'SK', 'TH', 'TN', 'TW', 'UA', 'US', 'ZA', 'ZM']` OR `'any'`. If 'any' is used, function will check if any of the locales match. Locale list is `validator.isPostalCodeLocales`.
|
153
|
+
**isRFC3339(str)** | check if the string is a valid [RFC 3339][RFC 3339] date.
|
154
|
+
**isRgbColor(str [, includePercentValues])** | check if the string is a rgb or rgba color.<br/><br/>`includePercentValues` defaults to `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.
|
155
|
+
**isSemVer(str)** | check if the string is a Semantic Versioning Specification (SemVer).
|
156
|
+
**isSurrogatePair(str)** | check if the string contains any surrogate pairs chars.
|
157
|
+
**isUppercase(str)** | check if the string is uppercase.
|
158
|
+
**isSlug(str)** | check if the string is of type slug.
|
159
|
+
**isStrongPassword(str [, options])** | check if the string can be considered a strong password or not. Allows for custom requirements or scoring rules. If `returnScore` is true, then the function returns an integer score for the password rather than a boolean.<br/>Default options: <br/>`{ minLength: 8, minLowercase: 1, minUppercase: 1, minNumbers: 1, minSymbols: 1, returnScore: false, pointsPerUnique: 1, pointsPerRepeat: 0.5, pointsForContainingLower: 10, pointsForContainingUpper: 10, pointsForContainingNumber: 10, pointsForContainingSymbol: 10 }`
|
160
|
+
**isTime(str [, options])** | check if the string is a valid time e.g. [`23:01:59`, new Date().toLocaleTimeString()].<br/><br/> `options` is an object which can contain the keys `hourFormat` or `mode`.<br/><br/>`hourFormat` is a key and defaults to `'hour24'`.<br/><br/>`mode` is a key and defaults to `'default'`. <br/><br/>`hourFomat` can contain the values `'hour12'` or `'hour24'`, `'hour24'` will validate hours in 24 format and `'hour12'` will validate hours in 12 format. <br/><br/>`mode` can contain the values `'default'` or `'withSeconds'`, `'default'` will validate `HH:MM` format, `'withSeconds'` will validate the `HH:MM:SS` format.
|
161
|
+
**isTaxID(str, locale)** | check if the string is a valid Tax Identification Number. Default locale is `en-US`.<br/><br/>More info about exact TIN support can be found in `src/lib/isTaxID.js`.<br/><br/>Supported locales: `[ 'bg-BG', 'cs-CZ', 'de-AT', 'de-DE', 'dk-DK', 'el-CY', 'el-GR', 'en-CA', 'en-GB', 'en-IE', 'en-US', 'es-AR', 'es-ES', 'et-EE', 'fi-FI', 'fr-BE', 'fr-CA', 'fr-FR', 'fr-LU', 'hr-HR', 'hu-HU', 'it-IT', 'lb-LU', 'lt-LT', 'lv-LV', 'mt-MT', 'nl-BE', 'nl-NL', 'pl-PL', 'pt-BR', 'pt-PT', 'ro-RO', 'sk-SK', 'sl-SI', 'sv-SE', 'uk-UA']`.
|
162
|
+
**isURL(str [, options])** | check if the string is a URL.<br/><br/>`options` is an object which defaults to `{ protocols: ['http','https','ftp'], require_tld: true, require_protocol: false, require_host: true, require_port: false, require_valid_protocol: true, allow_underscores: false, host_whitelist: false, host_blacklist: false, allow_trailing_dot: false, allow_protocol_relative_urls: false, allow_fragments: true, allow_query_components: true, disallow_auth: false, validate_length: true }`.<br/><br/>`require_protocol` - if set to true isURL will return false if protocol is not present in the URL.<br/>`require_valid_protocol` - isURL will check if the URL's protocol is present in the protocols option.<br/>`protocols` - valid protocols can be modified with this option.<br/>`require_host` - if set to false isURL will not check if host is present in the URL.<br/>`require_port` - if set to true isURL will check if port is present in the URL.<br/>`allow_protocol_relative_urls` - if set to true protocol relative URLs will be allowed.<br/>`allow_fragments` - if set to false isURL will return false if fragments are present.<br/>`allow_query_components` - if set to false isURL will return false if query components are present.<br/>`validate_length` - if set to false isURL will skip string length validation (2083 characters is IE max URL length).
|
163
|
+
**isUUID(str [, version])** | check if the string is a UUID (version 1, 2, 3, 4 or 5).
|
164
|
+
**isVariableWidth(str)** | check if the string contains a mixture of full and half-width chars.
|
165
|
+
**isVAT(str, countryCode)** | check if the string is a [valid VAT number][VAT Number] if validation is available for the given country code matching [ISO 3166-1 alpha-2][ISO 3166-1 alpha-2]. <br/><br/>`countryCode` is one of `['AL', 'AR', 'AT', 'AU', 'BE', 'BG', 'BO', 'BR', 'BY', 'CA', 'CH', 'CL', 'CO', 'CR', 'CY', 'CZ', 'DE', 'DK', 'DO', 'EC', 'EE', 'EL', 'ES', 'FI', 'FR', 'GB', 'GT', 'HN', 'HR', 'HU', 'ID', 'IE', 'IL', 'IN', 'IS', 'IT', 'KZ', 'LT', 'LU', 'LV', 'MK', 'MT', 'MX', 'NG', 'NI', 'NL', 'NO', 'NZ', 'PA', 'PE', 'PH', 'PL', 'PT', 'PY', 'RO', 'RS', 'RU', 'SA', 'SE', 'SI', 'SK', 'SM', 'SV', 'TR', 'UA', 'UY', 'UZ', 'VE']`.
|
166
|
+
**isWhitelisted(str, chars)** | check if the string consists only of characters that appear in the whitelist `chars`.
|
167
|
+
**matches(str, pattern [, modifiers])** | check if the string matches the pattern.<br/><br/>Either `matches('foo', /foo/i)` or `matches('foo', 'foo', 'i')`.
|
168
|
+
|
169
|
+
## Sanitizers
|
170
|
+
|
171
|
+
Here is a list of the sanitizers currently available.
|
172
|
+
|
173
|
+
Sanitizer | Description
|
174
|
+
-------------------------------------- | -------------------------------
|
175
|
+
**blacklist(input, chars)** | remove characters that appear in the blacklist. The characters are used in a RegExp and so you will need to escape some chars, e.g. `blacklist(input, '\\[\\]')`.
|
176
|
+
**escape(input)** | replace `<`, `>`, `&`, `'`, `"` and `/` with HTML entities.
|
177
|
+
**ltrim(input [, chars])** | trim characters from the left-side of the input.
|
178
|
+
**normalizeEmail(email [, options])** | canonicalize an email address. (This doesn't validate that the input is an email, if you want to validate the email use isEmail beforehand).<br/><br/>`options` is an object with the following keys and default values:<br/><ul><li>*all_lowercase: true* - 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 is case insensitive per RFC 1035.</li><li>*gmail_lowercase: true* - 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.</li><li>*gmail_remove_dots: true*: Removes dots from the local part of the email address, as Gmail ignores them (e.g. "john.doe" and "johndoe" are considered equal).</li><li>*gmail_remove_subaddress: true*: Normalizes addresses by removing "sub-addresses", which is the part following a "+" sign (e.g. "foo+bar@gmail.com" becomes "foo@gmail.com").</li><li>*gmail_convert_googlemaildotcom: true*: Converts addresses with domain @googlemail.com to @gmail.com, as they're equivalent.</li><li>*outlookdotcom_lowercase: true* - 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.</li><li>*outlookdotcom_remove_subaddress: true*: Normalizes addresses by removing "sub-addresses", which is the part following a "+" sign (e.g. "foo+bar@outlook.com" becomes "foo@outlook.com").</li><li>*yahoo_lowercase: true* - 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.</li><li>*yahoo_remove_subaddress: true*: Normalizes addresses by removing "sub-addresses", which is the part following a "-" sign (e.g. "foo-bar@yahoo.com" becomes "foo@yahoo.com").</li><li>*icloud_lowercase: true* - 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.</li><li>*icloud_remove_subaddress: true*: Normalizes addresses by removing "sub-addresses", which is the part following a "+" sign (e.g. "foo+bar@icloud.com" becomes "foo@icloud.com").</li></ul>
|
179
|
+
**rtrim(input [, chars])** | trim characters from the right-side of the input.
|
180
|
+
**stripLow(input [, keep_new_lines])** | remove characters with a numerical value < 32 and 127, mostly control characters. If `keep_new_lines` is `true`, newline characters are preserved (`\n` and `\r`, hex `0xA` and `0xD`). Unicode-safe in JavaScript.
|
181
|
+
**toBoolean(input [, strict])** | convert the input string to a boolean. Everything except for `'0'`, `'false'` and `''` returns `true`. In strict mode only `'1'` and `'true'` return `true`.
|
182
|
+
**toDate(input)** | convert the input string to a date, or `null` if the input is not a date.
|
183
|
+
**toFloat(input)** | convert the input string to a float, or `NaN` if the input is not a float.
|
184
|
+
**toInt(input [, radix])** | convert the input string to an integer, or `NaN` if the input is not an integer.
|
185
|
+
**trim(input [, chars])** | trim characters (whitespace by default) from both sides of the input.
|
186
|
+
**unescape(input)** | replace HTML encoded entities with `<`, `>`, `&`, `'`, `"` and `/`.
|
187
|
+
**whitelist(input, chars)** | remove characters that do not appear in the whitelist. The characters are used in a RegExp and so you will need to escape some chars, e.g. `whitelist(input, '\\[\\]')`.
|
188
|
+
|
189
|
+
### XSS Sanitization
|
190
|
+
|
191
|
+
XSS sanitization was removed from the library in [2d5d6999](https://github.com/validatorjs/validator.js/commit/2d5d6999541add350fb396ef02dc42ca3215049e).
|
192
|
+
|
193
|
+
For an alternative, have a look at Yahoo's [xss-filters library](https://github.com/yahoo/xss-filters) or at [DOMPurify](https://github.com/cure53/DOMPurify).
|
194
|
+
|
195
|
+
## Maintainers
|
196
|
+
|
197
|
+
- [chriso](https://github.com/chriso) - **Chris O'Hara** (author)
|
198
|
+
- [profnandaa](https://github.com/profnandaa) - **Anthony Nandaa**
|
199
|
+
- [ezkemboi](https://github.com/ezkemboi) - **Ezrqn Kemboi**
|
200
|
+
- [tux-tn](https://github.com/tux-tn) - **Sarhan Aissi**
|
201
|
+
|
202
|
+
## Reading
|
203
|
+
|
204
|
+
Remember, validating can be troublesome sometimes. See [A list of articles about programming assumptions commonly made that aren't true](https://github.com/jameslk/awesome-falsehoods).
|
205
|
+
|
206
|
+
## License (MIT)
|
207
|
+
|
208
|
+
```
|
209
|
+
Copyright (c) 2018 Chris O'Hara <cohara87@gmail.com>
|
210
|
+
|
211
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
212
|
+
a copy of this software and associated documentation files (the
|
213
|
+
"Software"), to deal in the Software without restriction, including
|
214
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
215
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
216
|
+
permit persons to whom the Software is furnished to do so, subject to
|
217
|
+
the following conditions:
|
218
|
+
|
219
|
+
The above copyright notice and this permission notice shall be
|
220
|
+
included in all copies or substantial portions of the Software.
|
221
|
+
|
222
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
223
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
224
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
225
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
226
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
227
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
228
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
229
|
+
```
|
230
|
+
|
231
|
+
[downloads-image]: http://img.shields.io/npm/dm/validator.svg
|
232
|
+
|
233
|
+
[npm-url]: https://npmjs.org/package/validator
|
234
|
+
[npm-image]: http://img.shields.io/npm/v/validator.svg
|
235
|
+
|
236
|
+
[codecov-url]: https://codecov.io/gh/validatorjs/validator.js
|
237
|
+
[codecov-image]: https://codecov.io/gh/validatorjs/validator.js/branch/master/graph/badge.svg
|
238
|
+
|
239
|
+
[ci-url]: https://github.com/validatorjs/validator.js/actions?query=workflow%3ACI
|
240
|
+
[ci-image]: https://github.com/validatorjs/validator.js/workflows/CI/badge.svg?branch=master
|
241
|
+
|
242
|
+
[gitter-url]: https://gitter.im/validatorjs/community
|
243
|
+
[gitter-image]: https://badges.gitter.im/validatorjs/community.svg
|
244
|
+
|
245
|
+
[huntr-url]: https://huntr.dev/bounties/disclose/?target=https://github.com/validatorjs/validator.js
|
246
|
+
[huntr-image]: https://cdn.huntr.dev/huntr_security_badge_mono.svg
|
247
|
+
|
248
|
+
[amd]: http://requirejs.org/docs/whyamd.html
|
249
|
+
[bower]: http://bower.io/
|
250
|
+
|
251
|
+
[Crockford Base32]: http://www.crockford.com/base32.html
|
252
|
+
[Base64 URL Safe]: https://base64.guru/standards/base64url
|
253
|
+
[Data URI Format]: https://developer.mozilla.org/en-US/docs/Web/HTTP/data_URIs
|
254
|
+
[European Article Number]: https://en.wikipedia.org/wiki/International_Article_Number
|
255
|
+
[Ethereum]: https://ethereum.org/
|
256
|
+
[CSS Colors Level 4 Specification]: https://developer.mozilla.org/en-US/docs/Web/CSS/color_value
|
257
|
+
[IMEI]: https://en.wikipedia.org/wiki/International_Mobile_Equipment_Identity
|
258
|
+
[ISBN]: https://en.wikipedia.org/wiki/ISBN
|
259
|
+
[ISIN]: https://en.wikipedia.org/wiki/International_Securities_Identification_Number
|
260
|
+
[ISO 639-1]: https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes
|
261
|
+
[ISO 8601]: https://en.wikipedia.org/wiki/ISO_8601
|
262
|
+
[ISO 3166-1 alpha-2]: https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2
|
263
|
+
[ISO 3166-1 alpha-3]: https://en.wikipedia.org/wiki/ISO_3166-1_alpha-3
|
264
|
+
[ISO 4217]: https://en.wikipedia.org/wiki/ISO_4217
|
265
|
+
[ISRC]: https://en.wikipedia.org/wiki/International_Standard_Recording_Code
|
266
|
+
[ISSN]: https://en.wikipedia.org/wiki/International_Standard_Serial_Number
|
267
|
+
[Luhn Check]: https://en.wikipedia.org/wiki/Luhn_algorithm
|
268
|
+
[Magnet URI Format]: https://en.wikipedia.org/wiki/Magnet_URI_scheme
|
269
|
+
[Mailto URI Format]: https://en.wikipedia.org/wiki/Mailto
|
270
|
+
[MIME Type]: https://en.wikipedia.org/wiki/Media_type
|
271
|
+
[mongoid]: http://docs.mongodb.org/manual/reference/object-id/
|
272
|
+
[RFC 3339]: https://tools.ietf.org/html/rfc3339
|
273
|
+
[VAT Number]: https://en.wikipedia.org/wiki/VAT_identification_number
|
package/es/index.js
ADDED
@@ -0,0 +1,211 @@
|
|
1
|
+
import toDate from './lib/toDate';
|
2
|
+
import toFloat from './lib/toFloat';
|
3
|
+
import toInt from './lib/toInt';
|
4
|
+
import toBoolean from './lib/toBoolean';
|
5
|
+
import equals from './lib/equals';
|
6
|
+
import contains from './lib/contains';
|
7
|
+
import matches from './lib/matches';
|
8
|
+
import isEmail from './lib/isEmail';
|
9
|
+
import isURL from './lib/isURL';
|
10
|
+
import isMACAddress from './lib/isMACAddress';
|
11
|
+
import isIP from './lib/isIP';
|
12
|
+
import isIPRange from './lib/isIPRange';
|
13
|
+
import isFQDN from './lib/isFQDN';
|
14
|
+
import isDate from './lib/isDate';
|
15
|
+
import isTime from './lib/isTime';
|
16
|
+
import isBoolean from './lib/isBoolean';
|
17
|
+
import isLocale from './lib/isLocale';
|
18
|
+
import isAbaRouting from './lib/isAbaRouting';
|
19
|
+
import isAlpha, { locales as isAlphaLocales } from './lib/isAlpha';
|
20
|
+
import isAlphanumeric, { locales as isAlphanumericLocales } from './lib/isAlphanumeric';
|
21
|
+
import isNumeric from './lib/isNumeric';
|
22
|
+
import isPassportNumber from './lib/isPassportNumber';
|
23
|
+
import isPort from './lib/isPort';
|
24
|
+
import isLowercase from './lib/isLowercase';
|
25
|
+
import isUppercase from './lib/isUppercase';
|
26
|
+
import isIMEI from './lib/isIMEI';
|
27
|
+
import isAscii from './lib/isAscii';
|
28
|
+
import isFullWidth from './lib/isFullWidth';
|
29
|
+
import isHalfWidth from './lib/isHalfWidth';
|
30
|
+
import isVariableWidth from './lib/isVariableWidth';
|
31
|
+
import isMultibyte from './lib/isMultibyte';
|
32
|
+
import isSemVer from './lib/isSemVer';
|
33
|
+
import isSurrogatePair from './lib/isSurrogatePair';
|
34
|
+
import isInt from './lib/isInt';
|
35
|
+
import isFloat, { locales as isFloatLocales } from './lib/isFloat';
|
36
|
+
import isDecimal from './lib/isDecimal';
|
37
|
+
import isHexadecimal from './lib/isHexadecimal';
|
38
|
+
import isOctal from './lib/isOctal';
|
39
|
+
import isDivisibleBy from './lib/isDivisibleBy';
|
40
|
+
import isHexColor from './lib/isHexColor';
|
41
|
+
import isRgbColor from './lib/isRgbColor';
|
42
|
+
import isHSL from './lib/isHSL';
|
43
|
+
import isISRC from './lib/isISRC';
|
44
|
+
import isIBAN, { locales as ibanLocales } from './lib/isIBAN';
|
45
|
+
import isBIC from './lib/isBIC';
|
46
|
+
import isMD5 from './lib/isMD5';
|
47
|
+
import isHash from './lib/isHash';
|
48
|
+
import isJWT from './lib/isJWT';
|
49
|
+
import isJSON from './lib/isJSON';
|
50
|
+
import isEmpty from './lib/isEmpty';
|
51
|
+
import isLength from './lib/isLength';
|
52
|
+
import isByteLength from './lib/isByteLength';
|
53
|
+
import isUUID from './lib/isUUID';
|
54
|
+
import isMongoId from './lib/isMongoId';
|
55
|
+
import isAfter from './lib/isAfter';
|
56
|
+
import isBefore from './lib/isBefore';
|
57
|
+
import isIn from './lib/isIn';
|
58
|
+
import isLuhnNumber from './lib/isLuhnNumber';
|
59
|
+
import isCreditCard from './lib/isCreditCard';
|
60
|
+
import isIdentityCard from './lib/isIdentityCard';
|
61
|
+
import isEAN from './lib/isEAN';
|
62
|
+
import isISIN from './lib/isISIN';
|
63
|
+
import isISBN from './lib/isISBN';
|
64
|
+
import isISSN from './lib/isISSN';
|
65
|
+
import isTaxID from './lib/isTaxID';
|
66
|
+
import isMobilePhone, { locales as isMobilePhoneLocales } from './lib/isMobilePhone';
|
67
|
+
import isEthereumAddress from './lib/isEthereumAddress';
|
68
|
+
import isCurrency from './lib/isCurrency';
|
69
|
+
import isBtcAddress from './lib/isBtcAddress';
|
70
|
+
import { isISO6346, isFreightContainerID } from './lib/isISO6346';
|
71
|
+
import isISO6391 from './lib/isISO6391';
|
72
|
+
import isISO8601 from './lib/isISO8601';
|
73
|
+
import isRFC3339 from './lib/isRFC3339';
|
74
|
+
import isISO31661Alpha2 from './lib/isISO31661Alpha2';
|
75
|
+
import isISO31661Alpha3 from './lib/isISO31661Alpha3';
|
76
|
+
import isISO4217 from './lib/isISO4217';
|
77
|
+
import isBase32 from './lib/isBase32';
|
78
|
+
import isBase58 from './lib/isBase58';
|
79
|
+
import isBase64 from './lib/isBase64';
|
80
|
+
import isDataURI from './lib/isDataURI';
|
81
|
+
import isMagnetURI from './lib/isMagnetURI';
|
82
|
+
import isMailtoURI from './lib/isMailtoURI';
|
83
|
+
import isMimeType from './lib/isMimeType';
|
84
|
+
import isLatLong from './lib/isLatLong';
|
85
|
+
import isPostalCode, { locales as isPostalCodeLocales } from './lib/isPostalCode';
|
86
|
+
import ltrim from './lib/ltrim';
|
87
|
+
import rtrim from './lib/rtrim';
|
88
|
+
import trim from './lib/trim';
|
89
|
+
import escape from './lib/escape';
|
90
|
+
import unescape from './lib/unescape';
|
91
|
+
import stripLow from './lib/stripLow';
|
92
|
+
import whitelist from './lib/whitelist';
|
93
|
+
import blacklist from './lib/blacklist';
|
94
|
+
import isWhitelisted from './lib/isWhitelisted';
|
95
|
+
import normalizeEmail from './lib/normalizeEmail';
|
96
|
+
import isSlug from './lib/isSlug';
|
97
|
+
import isLicensePlate from './lib/isLicensePlate';
|
98
|
+
import isStrongPassword from './lib/isStrongPassword';
|
99
|
+
import isVAT from './lib/isVAT';
|
100
|
+
var version = '13.12.0';
|
101
|
+
var validator = {
|
102
|
+
version: version,
|
103
|
+
toDate: toDate,
|
104
|
+
toFloat: toFloat,
|
105
|
+
toInt: toInt,
|
106
|
+
toBoolean: toBoolean,
|
107
|
+
equals: equals,
|
108
|
+
contains: contains,
|
109
|
+
matches: matches,
|
110
|
+
isEmail: isEmail,
|
111
|
+
isURL: isURL,
|
112
|
+
isMACAddress: isMACAddress,
|
113
|
+
isIP: isIP,
|
114
|
+
isIPRange: isIPRange,
|
115
|
+
isFQDN: isFQDN,
|
116
|
+
isBoolean: isBoolean,
|
117
|
+
isIBAN: isIBAN,
|
118
|
+
isBIC: isBIC,
|
119
|
+
isAbaRouting: isAbaRouting,
|
120
|
+
isAlpha: isAlpha,
|
121
|
+
isAlphaLocales: isAlphaLocales,
|
122
|
+
isAlphanumeric: isAlphanumeric,
|
123
|
+
isAlphanumericLocales: isAlphanumericLocales,
|
124
|
+
isNumeric: isNumeric,
|
125
|
+
isPassportNumber: isPassportNumber,
|
126
|
+
isPort: isPort,
|
127
|
+
isLowercase: isLowercase,
|
128
|
+
isUppercase: isUppercase,
|
129
|
+
isAscii: isAscii,
|
130
|
+
isFullWidth: isFullWidth,
|
131
|
+
isHalfWidth: isHalfWidth,
|
132
|
+
isVariableWidth: isVariableWidth,
|
133
|
+
isMultibyte: isMultibyte,
|
134
|
+
isSemVer: isSemVer,
|
135
|
+
isSurrogatePair: isSurrogatePair,
|
136
|
+
isInt: isInt,
|
137
|
+
isIMEI: isIMEI,
|
138
|
+
isFloat: isFloat,
|
139
|
+
isFloatLocales: isFloatLocales,
|
140
|
+
isDecimal: isDecimal,
|
141
|
+
isHexadecimal: isHexadecimal,
|
142
|
+
isOctal: isOctal,
|
143
|
+
isDivisibleBy: isDivisibleBy,
|
144
|
+
isHexColor: isHexColor,
|
145
|
+
isRgbColor: isRgbColor,
|
146
|
+
isHSL: isHSL,
|
147
|
+
isISRC: isISRC,
|
148
|
+
isMD5: isMD5,
|
149
|
+
isHash: isHash,
|
150
|
+
isJWT: isJWT,
|
151
|
+
isJSON: isJSON,
|
152
|
+
isEmpty: isEmpty,
|
153
|
+
isLength: isLength,
|
154
|
+
isLocale: isLocale,
|
155
|
+
isByteLength: isByteLength,
|
156
|
+
isUUID: isUUID,
|
157
|
+
isMongoId: isMongoId,
|
158
|
+
isAfter: isAfter,
|
159
|
+
isBefore: isBefore,
|
160
|
+
isIn: isIn,
|
161
|
+
isLuhnNumber: isLuhnNumber,
|
162
|
+
isCreditCard: isCreditCard,
|
163
|
+
isIdentityCard: isIdentityCard,
|
164
|
+
isEAN: isEAN,
|
165
|
+
isISIN: isISIN,
|
166
|
+
isISBN: isISBN,
|
167
|
+
isISSN: isISSN,
|
168
|
+
isMobilePhone: isMobilePhone,
|
169
|
+
isMobilePhoneLocales: isMobilePhoneLocales,
|
170
|
+
isPostalCode: isPostalCode,
|
171
|
+
isPostalCodeLocales: isPostalCodeLocales,
|
172
|
+
isEthereumAddress: isEthereumAddress,
|
173
|
+
isCurrency: isCurrency,
|
174
|
+
isBtcAddress: isBtcAddress,
|
175
|
+
isISO6346: isISO6346,
|
176
|
+
isFreightContainerID: isFreightContainerID,
|
177
|
+
isISO6391: isISO6391,
|
178
|
+
isISO8601: isISO8601,
|
179
|
+
isRFC3339: isRFC3339,
|
180
|
+
isISO31661Alpha2: isISO31661Alpha2,
|
181
|
+
isISO31661Alpha3: isISO31661Alpha3,
|
182
|
+
isISO4217: isISO4217,
|
183
|
+
isBase32: isBase32,
|
184
|
+
isBase58: isBase58,
|
185
|
+
isBase64: isBase64,
|
186
|
+
isDataURI: isDataURI,
|
187
|
+
isMagnetURI: isMagnetURI,
|
188
|
+
isMailtoURI: isMailtoURI,
|
189
|
+
isMimeType: isMimeType,
|
190
|
+
isLatLong: isLatLong,
|
191
|
+
ltrim: ltrim,
|
192
|
+
rtrim: rtrim,
|
193
|
+
trim: trim,
|
194
|
+
escape: escape,
|
195
|
+
unescape: unescape,
|
196
|
+
stripLow: stripLow,
|
197
|
+
whitelist: whitelist,
|
198
|
+
blacklist: blacklist,
|
199
|
+
isWhitelisted: isWhitelisted,
|
200
|
+
normalizeEmail: normalizeEmail,
|
201
|
+
toString: toString,
|
202
|
+
isSlug: isSlug,
|
203
|
+
isStrongPassword: isStrongPassword,
|
204
|
+
isTaxID: isTaxID,
|
205
|
+
isDate: isDate,
|
206
|
+
isTime: isTime,
|
207
|
+
isLicensePlate: isLicensePlate,
|
208
|
+
isVAT: isVAT,
|
209
|
+
ibanLocales: ibanLocales
|
210
|
+
};
|
211
|
+
export default validator;
|