-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
109 changed files
with
2,979 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,24 @@ | ||
{ | ||
"presets": [ | ||
["@babel/preset-env", {"targets": {"node": "0.10"}}] | ||
], | ||
"plugins": [ | ||
[ | ||
"add-module-exports", | ||
{ | ||
"addDefaultProperty": true | ||
} | ||
] | ||
] | ||
} | ||
"env": { | ||
"es": { | ||
"presets": [ | ||
["@babel/preset-env", { | ||
"modules": false | ||
}] | ||
] | ||
}, | ||
"development": { | ||
"presets": [ | ||
["@babel/preset-env", { "targets": { "node": "0.10" } }] | ||
], | ||
"plugins": [ | ||
[ | ||
"add-module-exports", | ||
{ | ||
"addDefaultProperty": true | ||
} | ||
] | ||
] | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,10 @@ sudo: false | |
language: node_js | ||
node_js: | ||
- stable | ||
- 12 | ||
- 11 | ||
- 10 | ||
- 9 | ||
- 8 | ||
notifications: | ||
email: false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,165 @@ | ||
import toDate from './lib/toDate'; | ||
import toFloat from './lib/toFloat'; | ||
import toInt from './lib/toInt'; | ||
import toBoolean from './lib/toBoolean'; | ||
import equals from './lib/equals'; | ||
import contains from './lib/contains'; | ||
import matches from './lib/matches'; | ||
import isEmail from './lib/isEmail'; | ||
import isURL from './lib/isURL'; | ||
import isMACAddress from './lib/isMACAddress'; | ||
import isIP from './lib/isIP'; | ||
import isIPRange from './lib/isIPRange'; | ||
import isFQDN from './lib/isFQDN'; | ||
import isBoolean from './lib/isBoolean'; | ||
import isLocale from './lib/isLocale'; | ||
import isAlpha, { locales as isAlphaLocales } from './lib/isAlpha'; | ||
import isAlphanumeric, { locales as isAlphanumericLocales } from './lib/isAlphanumeric'; | ||
import isNumeric from './lib/isNumeric'; | ||
import isPort from './lib/isPort'; | ||
import isLowercase from './lib/isLowercase'; | ||
import isUppercase from './lib/isUppercase'; | ||
import isAscii from './lib/isAscii'; | ||
import isFullWidth from './lib/isFullWidth'; | ||
import isHalfWidth from './lib/isHalfWidth'; | ||
import isVariableWidth from './lib/isVariableWidth'; | ||
import isMultibyte from './lib/isMultibyte'; | ||
import isSurrogatePair from './lib/isSurrogatePair'; | ||
import isInt from './lib/isInt'; | ||
import isFloat, { locales as isFloatLocales } from './lib/isFloat'; | ||
import isDecimal from './lib/isDecimal'; | ||
import isHexadecimal from './lib/isHexadecimal'; | ||
import isOctal from './lib/isOctal'; | ||
import isDivisibleBy from './lib/isDivisibleBy'; | ||
import isHexColor from './lib/isHexColor'; | ||
import isISRC from './lib/isISRC'; | ||
import isBIC from './lib/isBIC'; | ||
import isMD5 from './lib/isMD5'; | ||
import isHash from './lib/isHash'; | ||
import isJWT from './lib/isJWT'; | ||
import isJSON from './lib/isJSON'; | ||
import isEmpty from './lib/isEmpty'; | ||
import isLength from './lib/isLength'; | ||
import isByteLength from './lib/isByteLength'; | ||
import isUUID from './lib/isUUID'; | ||
import isMongoId from './lib/isMongoId'; | ||
import isAfter from './lib/isAfter'; | ||
import isBefore from './lib/isBefore'; | ||
import isIn from './lib/isIn'; | ||
import isCreditCard from './lib/isCreditCard'; | ||
import isIdentityCard from './lib/isIdentityCard'; | ||
import isISIN from './lib/isISIN'; | ||
import isISBN from './lib/isISBN'; | ||
import isISSN from './lib/isISSN'; | ||
import isMobilePhone, { locales as isMobilePhoneLocales } from './lib/isMobilePhone'; | ||
import isCurrency from './lib/isCurrency'; | ||
import isISO8601 from './lib/isISO8601'; | ||
import isRFC3339 from './lib/isRFC3339'; | ||
import isISO31661Alpha2 from './lib/isISO31661Alpha2'; | ||
import isISO31661Alpha3 from './lib/isISO31661Alpha3'; | ||
import isBase32 from './lib/isBase32'; | ||
import isBase64 from './lib/isBase64'; | ||
import isDataURI from './lib/isDataURI'; | ||
import isMagnetURI from './lib/isMagnetURI'; | ||
import isMimeType from './lib/isMimeType'; | ||
import isLatLong from './lib/isLatLong'; | ||
import isPostalCode, { locales as isPostalCodeLocales } from './lib/isPostalCode'; | ||
import ltrim from './lib/ltrim'; | ||
import rtrim from './lib/rtrim'; | ||
import trim from './lib/trim'; | ||
import escape from './lib/escape'; | ||
import unescape from './lib/unescape'; | ||
import stripLow from './lib/stripLow'; | ||
import whitelist from './lib/whitelist'; | ||
import blacklist from './lib/blacklist'; | ||
import isWhitelisted from './lib/isWhitelisted'; | ||
import normalizeEmail from './lib/normalizeEmail'; | ||
import isSlug from './lib/isSlug'; | ||
var version = '12.1.0'; | ||
var validator = { | ||
version: version, | ||
toDate: toDate, | ||
toFloat: toFloat, | ||
toInt: toInt, | ||
toBoolean: toBoolean, | ||
equals: equals, | ||
contains: contains, | ||
matches: matches, | ||
isEmail: isEmail, | ||
isURL: isURL, | ||
isMACAddress: isMACAddress, | ||
isIP: isIP, | ||
isIPRange: isIPRange, | ||
isFQDN: isFQDN, | ||
isBoolean: isBoolean, | ||
isBIC: isBIC, | ||
isAlpha: isAlpha, | ||
isAlphaLocales: isAlphaLocales, | ||
isAlphanumeric: isAlphanumeric, | ||
isAlphanumericLocales: isAlphanumericLocales, | ||
isNumeric: isNumeric, | ||
isPort: isPort, | ||
isLowercase: isLowercase, | ||
isUppercase: isUppercase, | ||
isAscii: isAscii, | ||
isFullWidth: isFullWidth, | ||
isHalfWidth: isHalfWidth, | ||
isVariableWidth: isVariableWidth, | ||
isMultibyte: isMultibyte, | ||
isSurrogatePair: isSurrogatePair, | ||
isInt: isInt, | ||
isFloat: isFloat, | ||
isFloatLocales: isFloatLocales, | ||
isDecimal: isDecimal, | ||
isHexadecimal: isHexadecimal, | ||
isOctal: isOctal, | ||
isDivisibleBy: isDivisibleBy, | ||
isHexColor: isHexColor, | ||
isISRC: isISRC, | ||
isMD5: isMD5, | ||
isHash: isHash, | ||
isJWT: isJWT, | ||
isJSON: isJSON, | ||
isEmpty: isEmpty, | ||
isLength: isLength, | ||
isLocale: isLocale, | ||
isByteLength: isByteLength, | ||
isUUID: isUUID, | ||
isMongoId: isMongoId, | ||
isAfter: isAfter, | ||
isBefore: isBefore, | ||
isIn: isIn, | ||
isCreditCard: isCreditCard, | ||
isIdentityCard: isIdentityCard, | ||
isISIN: isISIN, | ||
isISBN: isISBN, | ||
isISSN: isISSN, | ||
isMobilePhone: isMobilePhone, | ||
isMobilePhoneLocales: isMobilePhoneLocales, | ||
isPostalCode: isPostalCode, | ||
isPostalCodeLocales: isPostalCodeLocales, | ||
isCurrency: isCurrency, | ||
isISO8601: isISO8601, | ||
isRFC3339: isRFC3339, | ||
isISO31661Alpha2: isISO31661Alpha2, | ||
isISO31661Alpha3: isISO31661Alpha3, | ||
isBase32: isBase32, | ||
isBase64: isBase64, | ||
isDataURI: isDataURI, | ||
isMagnetURI: isMagnetURI, | ||
isMimeType: isMimeType, | ||
isLatLong: isLatLong, | ||
ltrim: ltrim, | ||
rtrim: rtrim, | ||
trim: trim, | ||
escape: escape, | ||
unescape: unescape, | ||
stripLow: stripLow, | ||
whitelist: whitelist, | ||
blacklist: blacklist, | ||
isWhitelisted: isWhitelisted, | ||
normalizeEmail: normalizeEmail, | ||
toString: toString, | ||
isSlug: isSlug | ||
}; | ||
export default validator; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
export var alpha = { | ||
'en-US': /^[A-Z]+$/i, | ||
'bg-BG': /^[А-Я]+$/i, | ||
'cs-CZ': /^[A-ZÁČĎÉĚÍŇÓŘŠŤÚŮÝŽ]+$/i, | ||
'da-DK': /^[A-ZÆØÅ]+$/i, | ||
'de-DE': /^[A-ZÄÖÜß]+$/i, | ||
'el-GR': /^[Α-ω]+$/i, | ||
'es-ES': /^[A-ZÁÉÍÑÓÚÜ]+$/i, | ||
'fr-FR': /^[A-ZÀÂÆÇÉÈÊËÏÎÔŒÙÛÜŸ]+$/i, | ||
'it-IT': /^[A-ZÀÉÈÌÎÓÒÙ]+$/i, | ||
'nb-NO': /^[A-ZÆØÅ]+$/i, | ||
'nl-NL': /^[A-ZÁÉËÏÓÖÜÚ]+$/i, | ||
'nn-NO': /^[A-ZÆØÅ]+$/i, | ||
'hu-HU': /^[A-ZÁÉÍÓÖŐÚÜŰ]+$/i, | ||
'pl-PL': /^[A-ZĄĆĘŚŁŃÓŻŹ]+$/i, | ||
'pt-PT': /^[A-ZÃÁÀÂÄÇÉÊËÍÏÕÓÔÖÚÜ]+$/i, | ||
'ru-RU': /^[А-ЯЁ]+$/i, | ||
'sl-SI': /^[A-ZČĆĐŠŽ]+$/i, | ||
'sk-SK': /^[A-ZÁČĎÉÍŇÓŠŤÚÝŽĹŔĽÄÔ]+$/i, | ||
'sr-RS@latin': /^[A-ZČĆŽŠĐ]+$/i, | ||
'sr-RS': /^[А-ЯЂЈЉЊЋЏ]+$/i, | ||
'sv-SE': /^[A-ZÅÄÖ]+$/i, | ||
'tr-TR': /^[A-ZÇĞİıÖŞÜ]+$/i, | ||
'uk-UA': /^[А-ЩЬЮЯЄIЇҐі]+$/i, | ||
'ku-IQ': /^[ئابپتجچحخدرڕزژسشعغفڤقکگلڵمنوۆھەیێيطؤثآإأكضصةظذ]+$/i, | ||
ar: /^[ءآأؤإئابةتثجحخدذرزسشصضطظعغفقكلمنهوىيًٌٍَُِّْٰ]+$/, | ||
he: /^[א-ת]+$/, | ||
'fa-IR': /^['آابپتثجچهخدذرزژسشصضطظعغفقکگلمنوهی']+$/i | ||
}; | ||
export var alphanumeric = { | ||
'en-US': /^[0-9A-Z]+$/i, | ||
'bg-BG': /^[0-9А-Я]+$/i, | ||
'cs-CZ': /^[0-9A-ZÁČĎÉĚÍŇÓŘŠŤÚŮÝŽ]+$/i, | ||
'da-DK': /^[0-9A-ZÆØÅ]+$/i, | ||
'de-DE': /^[0-9A-ZÄÖÜß]+$/i, | ||
'el-GR': /^[0-9Α-ω]+$/i, | ||
'es-ES': /^[0-9A-ZÁÉÍÑÓÚÜ]+$/i, | ||
'fr-FR': /^[0-9A-ZÀÂÆÇÉÈÊËÏÎÔŒÙÛÜŸ]+$/i, | ||
'it-IT': /^[0-9A-ZÀÉÈÌÎÓÒÙ]+$/i, | ||
'hu-HU': /^[0-9A-ZÁÉÍÓÖŐÚÜŰ]+$/i, | ||
'nb-NO': /^[0-9A-ZÆØÅ]+$/i, | ||
'nl-NL': /^[0-9A-ZÁÉËÏÓÖÜÚ]+$/i, | ||
'nn-NO': /^[0-9A-ZÆØÅ]+$/i, | ||
'pl-PL': /^[0-9A-ZĄĆĘŚŁŃÓŻŹ]+$/i, | ||
'pt-PT': /^[0-9A-ZÃÁÀÂÄÇÉÊËÍÏÕÓÔÖÚÜ]+$/i, | ||
'ru-RU': /^[0-9А-ЯЁ]+$/i, | ||
'sl-SI': /^[0-9A-ZČĆĐŠŽ]+$/i, | ||
'sk-SK': /^[0-9A-ZÁČĎÉÍŇÓŠŤÚÝŽĹŔĽÄÔ]+$/i, | ||
'sr-RS@latin': /^[0-9A-ZČĆŽŠĐ]+$/i, | ||
'sr-RS': /^[0-9А-ЯЂЈЉЊЋЏ]+$/i, | ||
'sv-SE': /^[0-9A-ZÅÄÖ]+$/i, | ||
'tr-TR': /^[0-9A-ZÇĞİıÖŞÜ]+$/i, | ||
'uk-UA': /^[0-9А-ЩЬЮЯЄIЇҐі]+$/i, | ||
'ku-IQ': /^[٠١٢٣٤٥٦٧٨٩0-9ئابپتجچحخدرڕزژسشعغفڤقکگلڵمنوۆھەیێيطؤثآإأكضصةظذ]+$/i, | ||
ar: /^[٠١٢٣٤٥٦٧٨٩0-9ءآأؤإئابةتثجحخدذرزسشصضطظعغفقكلمنهوىيًٌٍَُِّْٰ]+$/, | ||
he: /^[0-9א-ת]+$/, | ||
'fa-IR': /^['0-9آابپتثجچهخدذرزژسشصضطظعغفقکگلمنوهی۱۲۳۴۵۶۷۸۹۰']+$/i | ||
}; | ||
export var decimal = { | ||
'en-US': '.', | ||
ar: '٫' | ||
}; | ||
export var englishLocales = ['AU', 'GB', 'HK', 'IN', 'NZ', 'ZA', 'ZM']; | ||
|
||
for (var locale, i = 0; i < englishLocales.length; i++) { | ||
locale = "en-".concat(englishLocales[i]); | ||
alpha[locale] = alpha['en-US']; | ||
alphanumeric[locale] = alphanumeric['en-US']; | ||
decimal[locale] = decimal['en-US']; | ||
} // Source: http://www.localeplanet.com/java/ | ||
|
||
|
||
export var arabicLocales = ['AE', 'BH', 'DZ', 'EG', 'IQ', 'JO', 'KW', 'LB', 'LY', 'MA', 'QM', 'QA', 'SA', 'SD', 'SY', 'TN', 'YE']; | ||
|
||
for (var _locale, _i = 0; _i < arabicLocales.length; _i++) { | ||
_locale = "ar-".concat(arabicLocales[_i]); | ||
alpha[_locale] = alpha.ar; | ||
alphanumeric[_locale] = alphanumeric.ar; | ||
decimal[_locale] = decimal.ar; | ||
} // Source: https://en.wikipedia.org/wiki/Decimal_mark | ||
|
||
|
||
export var dotDecimal = ['ar-EG', 'ar-LB', 'ar-LY']; | ||
export var commaDecimal = ['bg-BG', 'cs-CZ', 'da-DK', 'de-DE', 'el-GR', 'en-ZM', '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']; | ||
|
||
for (var _i2 = 0; _i2 < dotDecimal.length; _i2++) { | ||
decimal[dotDecimal[_i2]] = decimal['en-US']; | ||
} | ||
|
||
for (var _i3 = 0; _i3 < commaDecimal.length; _i3++) { | ||
decimal[commaDecimal[_i3]] = ','; | ||
} | ||
|
||
alpha['pt-BR'] = alpha['pt-PT']; | ||
alphanumeric['pt-BR'] = alphanumeric['pt-PT']; | ||
decimal['pt-BR'] = decimal['pt-PT']; // see #862 | ||
|
||
alpha['pl-Pl'] = alpha['pl-PL']; | ||
alphanumeric['pl-Pl'] = alphanumeric['pl-PL']; | ||
decimal['pl-Pl'] = decimal['pl-PL']; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import assertString from './util/assertString'; | ||
export default function blacklist(str, chars) { | ||
assertString(str); | ||
return str.replace(new RegExp("[".concat(chars, "]+"), 'g'), ''); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import assertString from './util/assertString'; | ||
import toString from './util/toString'; | ||
export default function contains(str, elem) { | ||
assertString(str); | ||
return str.indexOf(toString(elem)) >= 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import assertString from './util/assertString'; | ||
export default function equals(str, comparison) { | ||
assertString(str); | ||
return str === comparison; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import assertString from './util/assertString'; | ||
export default function escape(str) { | ||
assertString(str); | ||
return str.replace(/&/g, '&').replace(/"/g, '"').replace(/'/g, ''').replace(/</g, '<').replace(/>/g, '>').replace(/\//g, '/').replace(/\\/g, '\').replace(/`/g, '`'); | ||
} |
Oops, something went wrong.