Skip to content

Commit

Permalink
Don't export the isISO8601 regular expression
Browse files Browse the repository at this point in the history
Now you can use the following, like other validators:

  const isISO8601 = require('validator/lib/isISO8601');

This fixes #688
  • Loading branch information
chriso committed Aug 22, 2017
1 parent e164140 commit b3e45da
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 12 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
17 changes: 9 additions & 8 deletions lib/isISO8601.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');

Expand All @@ -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 */
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'];
4 changes: 2 additions & 2 deletions src/lib/isISO8601.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
4 changes: 2 additions & 2 deletions validator.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down

0 comments on commit b3e45da

Please sign in to comment.