From b3e45daff655dca9218b3d04054ebf57c40c12df Mon Sep 17 00:00:00 2001 From: Chris O'Hara Date: Tue, 22 Aug 2017 18:19:08 +1000 Subject: [PATCH] Don't export the isISO8601 regular expression Now you can use the following, like other validators: const isISO8601 = require('validator/lib/isISO8601'); This fixes #688 --- CHANGELOG.md | 2 ++ lib/isISO8601.js | 17 +++++++++-------- src/lib/isISO8601.js | 4 ++-- validator.js | 4 ++-- 4 files changed, 15 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 47abc9922..78882552c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,7 @@ #### HEAD +- Fix `require('validator/lib/isIS8601')` calls + ([#688](https://github.com/chriso/validator.js/issues/688)) - Allow comma in email display names ([#692](https://github.com/chriso/validator.js/pull/692)) - Add missing string to unescape diff --git a/lib/isISO8601.js b/lib/isISO8601.js index edd6ae55c..e38f8611b 100644 --- a/lib/isISO8601.js +++ b/lib/isISO8601.js @@ -3,12 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); -exports.iso8601 = undefined; - -exports.default = function (str) { - (0, _assertString2.default)(str); - return iso8601.test(str); -}; +exports.default = isISO8601; var _assertString = require('./util/assertString'); @@ -18,5 +13,11 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de /* eslint-disable max-len */ // from http://goo.gl/0ejHHW -var iso8601 = exports.iso8601 = /^([\+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-2])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-3])((:?)[0-5]\d)?|24:?00)([\.,]\d+(?!:))?)?(\17[0-5]\d([\.,]\d+)?)?([zZ]|([\+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/; -/* eslint-enable max-len */ \ No newline at end of file +var iso8601 = /^([\+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-2])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-3])((:?)[0-5]\d)?|24:?00)([\.,]\d+(?!:))?)?(\17[0-5]\d([\.,]\d+)?)?([zZ]|([\+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/; +/* eslint-enable max-len */ + +function isISO8601(str) { + (0, _assertString2.default)(str); + return iso8601.test(str); +} +module.exports = exports['default']; \ No newline at end of file diff --git a/src/lib/isISO8601.js b/src/lib/isISO8601.js index a5d617fbf..7b24e5fe0 100644 --- a/src/lib/isISO8601.js +++ b/src/lib/isISO8601.js @@ -2,10 +2,10 @@ import assertString from './util/assertString'; /* eslint-disable max-len */ // from http://goo.gl/0ejHHW -export const iso8601 = /^([\+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-2])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-3])((:?)[0-5]\d)?|24:?00)([\.,]\d+(?!:))?)?(\17[0-5]\d([\.,]\d+)?)?([zZ]|([\+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/; +const iso8601 = /^([\+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-2])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-3])((:?)[0-5]\d)?|24:?00)([\.,]\d+(?!:))?)?(\17[0-5]\d([\.,]\d+)?)?([zZ]|([\+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/; /* eslint-enable max-len */ -export default function (str) { +export default function isISO8601(str) { assertString(str); return iso8601.test(str); } diff --git a/validator.js b/validator.js index 8913be631..fddbd4b33 100644 --- a/validator.js +++ b/validator.js @@ -1035,10 +1035,10 @@ function isCurrency(str, options) { var iso8601 = /^([\+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-2])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-3])((:?)[0-5]\d)?|24:?00)([\.,]\d+(?!:))?)?(\17[0-5]\d([\.,]\d+)?)?([zZ]|([\+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/; /* eslint-enable max-len */ -var isISO8601 = function (str) { +function isISO8601(str) { assertString(str); return iso8601.test(str); -}; +} var notBase64 = /[^A-Z0-9+\/=]/i;