Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sg and update from source #2

Merged
merged 54 commits into from
Oct 24, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
63e4c78
feat(isMobilePhone): add es-PY locale (Paraguay) (#1017)
gvuyk Apr 19, 2019
330ad51
fix: sync src/lib with lib
chriso May 23, 2019
074168a
chore: add JSON reference test case in isURL validator (#978)
GeorgeGkas May 23, 2019
57ed38f
feat(isEmail): validate display name according to RFC2822 (#1004)
hjaurum May 23, 2019
41a940f
feat(isEmail): check total email length (#1007)
AMRALAA10 May 23, 2019
fd7a793
fix(isMobilePhone): update zh-CN validation (#1022)
shianqi May 23, 2019
9fc9388
feat: add isBase32 validator (#1023)
razananisathar May 23, 2019
daaf1f7
fix(isMobilePhone): update vi-VN validation (#1031)
eightshone May 23, 2019
5830e66
fix(isMobilePhone): update bn-BD validation (#1032)
alouini333 May 23, 2019
c2ff8bf
fix: sync src/lib and lib
chriso May 23, 2019
0277eb0
chore: remove the toString util
chriso May 23, 2019
7c079b7
chore: remove toString export from combined version
chriso May 23, 2019
90cc022
11.0.0
chriso May 23, 2019
eb0bbba
feat(isMobilePhone): add Chile locale and additional prefix for KE lo…
ezkemboi May 24, 2019
81302a7
Create FUNDING.yml
chriso May 26, 2019
d7dbdd5
feat(isIdentityCard): add zh-TW locale (#1040)
fantasywind Jun 18, 2019
9ee09a7
chore: code coverage improvements (#1024)
tux-tn Jun 18, 2019
7735e0f
feat(isIdentityCard): add he-IL locale (#1041)
perimiter Jun 18, 2019
dcb2db0
fix: some fixes to isIdentityCard('he-IL') (#1048)
perimiter Jun 20, 2019
c5c0bf2
feat(isPostalCode): add BR and NZ locales (#1049)
tevaum Jun 23, 2019
f3f4070
#990. Clean up PR #991 (#1052)
ezkemboi Jul 1, 2019
1a2a868
feat(isMobilePhone): add nl-NL locale (#1054)
profnandaa Jul 2, 2019
20ad9b7
feat(isMobilePhone, isPostalCode): add support for Malta, en-MT (#1055)
profnandaa Jul 2, 2019
8d8dbeb
feat(isMobilePhone): add Bahrain locale (#1056)
heiba Jul 3, 2019
2f62084
feat(isPostalCode): add PR locale (#1057)
tevaum Jul 3, 2019
56cd1f0
11.1.0
chriso Jul 4, 2019
7125c57
feat(isMobile): add de-AT locale (#1059)
ezkemboi Jul 9, 2019
4aac1b7
feat(isMobilePhone): add france oversea department phone codes (#1060)
ezkemboi Jul 9, 2019
cf00ee6
fix(isHash): to include uppercase chars in hash (#1062)
ezkemboi Jul 24, 2019
02896f3
fix(isMACAddress): add use of hyphen or spaces in mac address (#1065)
ezkemboi Jul 24, 2019
54bf8c4
fix(isPostalCode): ensure sweedish postal code does not start with 0 …
ezkemboi Jul 25, 2019
25e84cf
fix(isMobilePhone): ja_JP locale (#1073)
yomotsu Aug 2, 2019
1ce76a1
fix(isLength): return true if min no supplied (#1070)
ezkemboi Aug 2, 2019
47f3492
fix(isLatLong): fix bug on brackets mismatch (#1074)
ezkemboi Aug 2, 2019
98b2ca6
fix(README): link to contributors (#1077)
profnandaa Aug 8, 2019
35a72b6
feat(isPostalCode): add Ireland support (#1083)
ezkemboi Aug 12, 2019
c265581
chore(isPostalCode): add test cases for BR (#1082)
ezkemboi Aug 12, 2019
23fcd9c
feat(isBIC): add isBIC validation (#1071)
ezkemboi Aug 17, 2019
a4ca952
feat(isMobilePhone): add Guernsey locale (#1092)
austenpayan Aug 20, 2019
b36b420
fix(#1092): add en-GG on README (#1093)
profnandaa Aug 20, 2019
ee038b6
fix: alphabetized the list of validators in README.md (#1110)
thedanfernandez Sep 20, 2019
b4672f4
fix: typo in README (#1126)
tomer Oct 5, 2019
242c3bf
feat: add hebrew support to isAlpha and isAlphanumeric (#1125)
tomer Oct 5, 2019
cff8a58
fix: update build status travis on README (#1124)
Tony133 Oct 5, 2019
72d9f55
feat: add fa-IR to isAlpha and isAlphanumeric (#1121)
pedramp Oct 6, 2019
3087572
fix(isMobilePhone): add new prefix for bn-BD (#1132)
MunifTanjim Oct 6, 2019
d18a8b8
fix(isPostalCode): postal code validation fix for locale IN (#1152)
adityaraval Oct 13, 2019
4162ae7
feat(isOctal): add new isOctal validator (#1153)
ayala-io Oct 13, 2019
1bf0094
fix: add validation for '0x'-prefixed hex strings (#1147)
ayala-io Oct 13, 2019
71c46e1
fix(README): update contribution section (#1143)
ezkemboi Oct 13, 2019
2222e5a
feat(isSlug): add isSlug validator (#1096)
Nicanor008 Oct 16, 2019
659a758
fix(isMobile): allow for extra formatting for ja-JP locale (#1166)
ayala-io Oct 18, 2019
2a80a4f
feat(isMobilePhone): add es-PA locale (#1165)
andrewhingah Oct 18, 2019
ca54eac
new buld
kishoreknowapp Oct 24, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
open_collective: validatorjs
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
.DS_Store
node_modules
coverage
.nyc_output
package-lock.json
yarn.lock
13 changes: 13 additions & 0 deletions .nycrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"reporter": [
"html",
"text-summary"
],
"include": [
"src/**/*.js"
],
"exclude": [
"validator.js",
"lib/**/*.js"
]
}
34 changes: 34 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,37 @@
#### 11.1.0

- Code coverage improvements
([#1024](https://github.com/chriso/validator.js/pull/1024))
- New and improved locales
([#1035](https://github.com/chriso/validator.js/pull/1035),
[#1040](https://github.com/chriso/validator.js/pull/1040),
[#1041](https://github.com/chriso/validator.js/pull/1041),
[#1048](https://github.com/chriso/validator.js/pull/1048),
[#1049](https://github.com/chriso/validator.js/pull/1049),
[#1052](https://github.com/chriso/validator.js/pull/1052),
[#1054](https://github.com/chriso/validator.js/pull/1054),
[#1055](https://github.com/chriso/validator.js/pull/1055),
[#1056](https://github.com/chriso/validator.js/pull/1056),
[#1057](https://github.com/chriso/validator.js/pull/1057))

#### 11.0.0

- Added a `isBase32()` validator
([#1023](https://github.com/chriso/validator.js/pull/1023))
- Updated `isEmail()` to validate display names according to RFC2822
([#1004](https://github.com/chriso/validator.js/pull/1004))
- Updated `isEmail()` to check total email length
([#1007](https://github.com/chriso/validator.js/pull/1007))
- The internal `toString()` util is no longer exported
([0277eb](https://github.com/chriso/validator.js/commit/0277eb00d245a3479af52adf7d927d4036895650))
- New and improved locales
([#999](https://github.com/chriso/validator.js/pull/999),
[#1010](https://github.com/chriso/validator.js/pull/1010),
[#1017](https://github.com/chriso/validator.js/pull/1017),
[#1022](https://github.com/chriso/validator.js/pull/1022),
[#1031](https://github.com/chriso/validator.js/pull/1031),
[#1032](https://github.com/chriso/validator.js/pull/1032))

#### 10.11.0

- Fix imports like `import .. from "validator/lib/.."`
Expand Down
42 changes: 24 additions & 18 deletions README.md

Large diffs are not rendered by default.

24 changes: 18 additions & 6 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,16 @@ var _isDecimal = _interopRequireDefault(require("./lib/isDecimal"));

var _isHexadecimal = _interopRequireDefault(require("./lib/isHexadecimal"));

var _isOctal = _interopRequireDefault(require("./lib/isOctal"));

var _isDivisibleBy = _interopRequireDefault(require("./lib/isDivisibleBy"));

var _isHexColor = _interopRequireDefault(require("./lib/isHexColor"));

var _isISRC = _interopRequireDefault(require("./lib/isISRC"));

var _isBIC = _interopRequireDefault(require("./lib/isBIC"));

var _isMD = _interopRequireDefault(require("./lib/isMD5"));

var _isHash = _interopRequireDefault(require("./lib/isHash"));
Expand Down Expand Up @@ -117,7 +121,9 @@ var _isISO31661Alpha = _interopRequireDefault(require("./lib/isISO31661Alpha2"))

var _isISO31661Alpha2 = _interopRequireDefault(require("./lib/isISO31661Alpha3"));

var _isBase = _interopRequireDefault(require("./lib/isBase64"));
var _isBase = _interopRequireDefault(require("./lib/isBase32"));

var _isBase2 = _interopRequireDefault(require("./lib/isBase64"));

var _isDataURI = _interopRequireDefault(require("./lib/isDataURI"));

Expand Down Expand Up @@ -149,13 +155,15 @@ var _isWhitelisted = _interopRequireDefault(require("./lib/isWhitelisted"));

var _normalizeEmail = _interopRequireDefault(require("./lib/normalizeEmail"));

var _toString = _interopRequireDefault(require("./lib/util/toString"));
var _isSlug = _interopRequireDefault(require("./lib/isSlug"));

function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; }

function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } }
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; if (obj != null) { var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

var version = '10.11.0';
var version = '11.1.0';
var validator = {
version: version,
toDate: _toDate.default,
Expand All @@ -172,6 +180,7 @@ var validator = {
isIPRange: _isIPRange.default,
isFQDN: _isFQDN.default,
isBoolean: _isBoolean.default,
isBIC: _isBIC.default,
isAlpha: _isAlpha.default,
isAlphaLocales: _isAlpha.locales,
isAlphanumeric: _isAlphanumeric.default,
Expand All @@ -191,6 +200,7 @@ var validator = {
isFloatLocales: _isFloat.locales,
isDecimal: _isDecimal.default,
isHexadecimal: _isHexadecimal.default,
isOctal: _isOctal.default,
isDivisibleBy: _isDivisibleBy.default,
isHexColor: _isHexColor.default,
isISRC: _isISRC.default,
Expand Down Expand Up @@ -220,7 +230,8 @@ var validator = {
isRFC3339: _isRFC.default,
isISO31661Alpha2: _isISO31661Alpha.default,
isISO31661Alpha3: _isISO31661Alpha2.default,
isBase64: _isBase.default,
isBase32: _isBase.default,
isBase64: _isBase2.default,
isDataURI: _isDataURI.default,
isMagnetURI: _isMagnetURI.default,
isMimeType: _isMimeType.default,
Expand All @@ -235,7 +246,8 @@ var validator = {
blacklist: _blacklist.default,
isWhitelisted: _isWhitelisted.default,
normalizeEmail: _normalizeEmail.default,
toString: _toString.default
toString: toString,
isSlug: _isSlug.default
};
var _default = validator;
exports.default = _default;
Expand Down
12 changes: 8 additions & 4 deletions lib/alpha.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ var alpha = {
'tr-TR': /^[A-ZÇĞİıÖŞÜ]+$/i,
'uk-UA': /^[А-ЩЬЮЯЄIЇҐі]+$/i,
'ku-IQ': /^[ئابپتجچحخدرڕزژسشعغفڤقکگلڵمنوۆھەیێيطؤثآإأكضصةظذ]+$/i,
ar: /^[ءآأؤإئابةتثجحخدذرزسشصضطظعغفقكلمنهوىيًٌٍَُِّْٰ]+$/
ar: /^[ءآأؤإئابةتثجحخدذرزسشصضطظعغفقكلمنهوىيًٌٍَُِّْٰ]+$/,
he: /^[א-ת]+$/,
'fa-IR': /^['آابپتثجچهخدذرزژسشصضطظعغفقکگلمنوهی']+$/i
};
exports.alpha = alpha;
var alphanumeric = {
Expand Down Expand Up @@ -57,7 +59,9 @@ var alphanumeric = {
'tr-TR': /^[0-9A-ZÇĞİıÖŞÜ]+$/i,
'uk-UA': /^[0-9А-ЩЬЮЯЄIЇҐі]+$/i,
'ku-IQ': /^[٠١٢٣٤٥٦٧٨٩0-9ئابپتجچحخدرڕزژسشعغفڤقکگلڵمنوۆھەیێيطؤثآإأكضصةظذ]+$/i,
ar: /^[٠١٢٣٤٥٦٧٨٩0-9ءآأؤإئابةتثجحخدذرزسشصضطظعغفقكلمنهوىيًٌٍَُِّْٰ]+$/
ar: /^[٠١٢٣٤٥٦٧٨٩0-9ءآأؤإئابةتثجحخدذرزسشصضطظعغفقكلمنهوىيًٌٍَُِّْٰ]+$/,
he: /^[0-9א-ת]+$/,
'fa-IR': /^['0-9آابپتثجچهخدذرزژسشصضطظعغفقکگلمنوهی۱۲۳۴۵۶۷۸۹۰']+$/i
};
exports.alphanumeric = alphanumeric;
var decimal = {
Expand Down Expand Up @@ -87,9 +91,9 @@ for (var _locale, _i = 0; _i < arabicLocales.length; _i++) {
} // Source: https://en.wikipedia.org/wiki/Decimal_mark


var dotDecimal = [];
var dotDecimal = ['ar-EG', 'ar-LB', 'ar-LY'];
exports.dotDecimal = dotDecimal;
var commaDecimal = ['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'];
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'];
exports.commaDecimal = commaDecimal;

for (var _i2 = 0; _i2 < dotDecimal.length; _i2++) {
Expand Down
20 changes: 20 additions & 0 deletions lib/isBIC.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
"use strict";

Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = isBIC;

var _assertString = _interopRequireDefault(require("./util/assertString"));

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

var isBICReg = /^[A-z]{4}[A-z]{2}\w{2}(\w{3})?$/;

function isBIC(str) {
(0, _assertString.default)(str);
return isBICReg.test(str);
}

module.exports = exports.default;
module.exports.default = exports.default;
26 changes: 26 additions & 0 deletions lib/isBase32.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
"use strict";

Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = isBase32;

var _assertString = _interopRequireDefault(require("./util/assertString"));

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

var base32 = /^[A-Z2-7]+=*$/;

function isBase32(str) {
(0, _assertString.default)(str);
var len = str.length;

if (len > 0 && len % 8 === 0 && base32.test(str)) {
return true;
}

return false;
}

module.exports = exports.default;
module.exports.default = exports.default;
74 changes: 69 additions & 5 deletions lib/isEmail.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,14 @@ var _isIP = _interopRequireDefault(require("./isIP"));

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); }

function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance"); }

function _iterableToArrayLimit(arr, i) { if (!(Symbol.iterator in Object(arr) || Object.prototype.toString.call(arr) === "[object Arguments]")) { return; } var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }

function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }

var default_email_options = {
allow_display_name: false,
require_display_name: false,
Expand All @@ -27,30 +35,86 @@ var default_email_options = {

/* eslint-disable no-control-regex */

var displayName = /^[a-z\d!#\$%&'\*\+\-\/=\?\^_`{\|}~\.\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+[a-z\d!#\$%&'\*\+\-\/=\?\^_`{\|}~\,\.\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF\s]*<(.+)>$/i;
var splitNameAddress = /^([^\x00-\x1F\x7F-\x9F\cX]+)<(.+)>$/i;
var emailUserPart = /^[a-z\d!#\$%&'\*\+\-\/=\?\^_`{\|}~]+$/i;
var gmailUserPart = /^[a-z\d]+$/;
var quotedEmailUser = /^([\s\x01-\x08\x0b\x0c\x0e-\x1f\x7f\x21\x23-\x5b\x5d-\x7e]|(\\[\x01-\x09\x0b\x0c\x0d-\x7f]))*$/i;
var emailUserUtf8Part = /^[a-z\d!#\$%&'\*\+\-\/=\?\^_`{\|}~\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+$/i;
var quotedEmailUserUtf8 = /^([\s\x01-\x08\x0b\x0c\x0e-\x1f\x7f\x21\x23-\x5b\x5d-\x7e\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]|(\\[\x01-\x09\x0b\x0c\x0d-\x7f\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))*$/i;
var defaultMaxEmailLength = 254;
/* eslint-enable max-len */

/* eslint-enable no-control-regex */

/**
* Validate display name according to the RFC2822: https://tools.ietf.org/html/rfc2822#appendix-A.1.2
* @param {String} display_name
*/

function validateDisplayName(display_name) {
var trim_quotes = display_name.match(/^"(.+)"$/i);
var display_name_without_quotes = trim_quotes ? trim_quotes[1] : display_name; // display name with only spaces is not valid

if (!display_name_without_quotes.trim()) {
return false;
} // check whether display name contains illegal character


var contains_illegal = /[\.";<>]/.test(display_name_without_quotes);

if (contains_illegal) {
// if contains illegal characters,
// must to be enclosed in double-quotes, otherwise it's not a valid display name
if (!trim_quotes) {
return false;
} // the quotes in display name must start with character symbol \


var all_start_with_back_slash = display_name_without_quotes.split('"').length === display_name_without_quotes.split('\\"').length;

if (!all_start_with_back_slash) {
return false;
}
}

return true;
}

function isEmail(str, options) {
(0, _assertString.default)(str);
options = (0, _merge.default)(options, default_email_options);

if (options.require_display_name || options.allow_display_name) {
var display_email = str.match(displayName);
var display_email = str.match(splitNameAddress);

if (display_email) {
str = display_email[1];
var display_name;

var _display_email = _slicedToArray(display_email, 3);

display_name = _display_email[1];
str = _display_email[2];

// sometimes need to trim the last space to get the display name
// because there may be a space between display name and email address
// eg. myname <address@gmail.com>
// the display name is `myname` instead of `myname `, so need to trim the last space
if (display_name.endsWith(' ')) {
display_name = display_name.substr(0, display_name.length - 1);
}

if (!validateDisplayName(display_name)) {
return false;
}
} else if (options.require_display_name) {
return false;
}
}

if (!options.ignore_max_length && str.length > defaultMaxEmailLength) {
return false;
}

var parts = str.split('@');
var domain = parts.pop();
var user = parts.join('@');
Expand Down Expand Up @@ -120,8 +184,8 @@ function isEmail(str, options) {
var pattern = options.allow_utf8_local_part ? emailUserUtf8Part : emailUserPart;
var user_parts = user.split('.');

for (var _i = 0; _i < user_parts.length; _i++) {
if (!pattern.test(user_parts[_i])) {
for (var _i2 = 0; _i2 < user_parts.length; _i2++) {
if (!pattern.test(user_parts[_i2])) {
return false;
}
}
Expand Down
2 changes: 1 addition & 1 deletion lib/isHash.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ var lengths = {

function isHash(str, algorithm) {
(0, _assertString.default)(str);
var hash = new RegExp("^[a-f0-9]{".concat(lengths[algorithm], "}$"));
var hash = new RegExp("^[a-fA-F0-9]{".concat(lengths[algorithm], "}$"));
return hash.test(str);
}

Expand Down
2 changes: 1 addition & 1 deletion lib/isHexadecimal.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ var _assertString = _interopRequireDefault(require("./util/assertString"));

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

var hexadecimal = /^[0-9A-F]+$/i;
var hexadecimal = /^(0x|0h)?[0-9A-F]+$/i;

function isHexadecimal(str) {
(0, _assertString.default)(str);
Expand Down
3 changes: 1 addition & 2 deletions lib/isISO8601.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ var isValidDate = function isValidDate(str) {
var oYear = Number(ordinalMatch[1]);
var oDay = Number(ordinalMatch[2]); // if is leap year

if (oYear % 4 === 0 && oYear % 100 !== 0) return oDay <= 366;
if (oYear % 4 === 0 && oYear % 100 !== 0 || oYear % 400 === 0) return oDay <= 366;
return oDay <= 365;
}

Expand All @@ -37,7 +37,6 @@ var isValidDate = function isValidDate(str) {
var dayString = day ? "0".concat(day).slice(-2) : day; // create a date object and compare

var d = new Date("".concat(year, "-").concat(monthString || '01', "-").concat(dayString || '01'));
if (isNaN(d.getUTCFullYear())) return false;

if (month && day) {
return d.getUTCFullYear() === year && d.getUTCMonth() + 1 === month && d.getUTCDate() === day;
Expand Down
Loading