async-validator
Advanced tools
Comparing version 4.0.3 to 4.0.4
@@ -5,121 +5,16 @@ 'use strict'; | ||
function _extends() { | ||
_extends = Object.assign || function (target) { | ||
for (var i = 1; i < arguments.length; i++) { | ||
var source = arguments[i]; | ||
var urlRegex = require('url-regex'); | ||
for (var key in source) { | ||
if (Object.prototype.hasOwnProperty.call(source, key)) { | ||
target[key] = source[key]; | ||
} | ||
} | ||
} | ||
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } | ||
return target; | ||
}; | ||
var urlRegex__default = /*#__PURE__*/_interopDefaultLegacy(urlRegex); | ||
return _extends.apply(this, arguments); | ||
} | ||
function _inheritsLoose(subClass, superClass) { | ||
subClass.prototype = Object.create(superClass.prototype); | ||
subClass.prototype.constructor = subClass; | ||
_setPrototypeOf(subClass, superClass); | ||
} | ||
function _getPrototypeOf(o) { | ||
_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { | ||
return o.__proto__ || Object.getPrototypeOf(o); | ||
}; | ||
return _getPrototypeOf(o); | ||
} | ||
function _setPrototypeOf(o, p) { | ||
_setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { | ||
o.__proto__ = p; | ||
return o; | ||
}; | ||
return _setPrototypeOf(o, p); | ||
} | ||
function _isNativeReflectConstruct() { | ||
if (typeof Reflect === "undefined" || !Reflect.construct) return false; | ||
if (Reflect.construct.sham) return false; | ||
if (typeof Proxy === "function") return true; | ||
try { | ||
Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); | ||
return true; | ||
} catch (e) { | ||
return false; | ||
} | ||
} | ||
function _construct(Parent, args, Class) { | ||
if (_isNativeReflectConstruct()) { | ||
_construct = Reflect.construct; | ||
} else { | ||
_construct = function _construct(Parent, args, Class) { | ||
var a = [null]; | ||
a.push.apply(a, args); | ||
var Constructor = Function.bind.apply(Parent, a); | ||
var instance = new Constructor(); | ||
if (Class) _setPrototypeOf(instance, Class.prototype); | ||
return instance; | ||
}; | ||
} | ||
return _construct.apply(null, arguments); | ||
} | ||
function _isNativeFunction(fn) { | ||
return Function.toString.call(fn).indexOf("[native code]") !== -1; | ||
} | ||
function _wrapNativeSuper(Class) { | ||
var _cache = typeof Map === "function" ? new Map() : undefined; | ||
_wrapNativeSuper = function _wrapNativeSuper(Class) { | ||
if (Class === null || !_isNativeFunction(Class)) return Class; | ||
if (typeof Class !== "function") { | ||
throw new TypeError("Super expression must either be null or a function"); | ||
} | ||
if (typeof _cache !== "undefined") { | ||
if (_cache.has(Class)) return _cache.get(Class); | ||
_cache.set(Class, Wrapper); | ||
} | ||
function Wrapper() { | ||
return _construct(Class, arguments, _getPrototypeOf(this).constructor); | ||
} | ||
Wrapper.prototype = Object.create(Class.prototype, { | ||
constructor: { | ||
value: Wrapper, | ||
enumerable: false, | ||
writable: true, | ||
configurable: true | ||
} | ||
}); | ||
return _setPrototypeOf(Wrapper, Class); | ||
}; | ||
return _wrapNativeSuper(Class); | ||
} | ||
/* eslint no-console:0 */ | ||
var formatRegExp = /%[sdj%]/g; | ||
var warning = function warning() {}; // don't print warning message when in production env or node runtime | ||
const formatRegExp = /%[sdj%]/g; | ||
let warning = () => {}; // don't print warning message when in production env or node runtime | ||
if (typeof process !== 'undefined' && process.env && process.env.NODE_ENV !== 'production' && typeof window !== 'undefined' && typeof document !== 'undefined') { | ||
warning = function warning(type, errors) { | ||
warning = (type, errors) => { | ||
if (typeof console !== 'undefined' && console.warn && typeof ASYNC_VALIDATOR_NO_WARNING === 'undefined') { | ||
if (errors.every(function (e) { | ||
return typeof e === 'string'; | ||
})) { | ||
if (errors.every(e => typeof e === 'string')) { | ||
console.warn(type, errors); | ||
@@ -133,5 +28,5 @@ } | ||
if (!errors || !errors.length) return null; | ||
var fields = {}; | ||
errors.forEach(function (error) { | ||
var field = error.field; | ||
const fields = {}; | ||
errors.forEach(error => { | ||
const field = error.field; | ||
fields[field] = fields[field] || []; | ||
@@ -142,10 +37,6 @@ fields[field].push(error); | ||
} | ||
function format(template) { | ||
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { | ||
args[_key - 1] = arguments[_key]; | ||
} | ||
function format(template, ...args) { | ||
let i = 0; | ||
const len = args.length; | ||
var i = 0; | ||
var len = args.length; | ||
if (typeof template === 'function') { | ||
@@ -156,3 +47,3 @@ return template.apply(null, args); | ||
if (typeof template === 'string') { | ||
var str = template.replace(formatRegExp, function (x) { | ||
let str = template.replace(formatRegExp, x => { | ||
if (x === '%%') { | ||
@@ -213,8 +104,8 @@ return '%'; | ||
function asyncParallelArray(arr, func, callback) { | ||
var results = []; | ||
var total = 0; | ||
var arrLength = arr.length; | ||
const results = []; | ||
let total = 0; | ||
const arrLength = arr.length; | ||
function count(errors) { | ||
results.push.apply(results, errors || []); | ||
results.push(...(errors || [])); | ||
total++; | ||
@@ -227,3 +118,3 @@ | ||
arr.forEach(function (a) { | ||
arr.forEach(a => { | ||
func(a, count); | ||
@@ -234,4 +125,4 @@ }); | ||
function asyncSerialArray(arr, func, callback) { | ||
var index = 0; | ||
var arrLength = arr.length; | ||
let index = 0; | ||
const arrLength = arr.length; | ||
@@ -244,3 +135,3 @@ function next(errors) { | ||
var original = index; | ||
const original = index; | ||
index = index + 1; | ||
@@ -259,5 +150,5 @@ | ||
function flattenObjArr(objArr) { | ||
var ret = []; | ||
Object.keys(objArr).forEach(function (k) { | ||
ret.push.apply(ret, objArr[k] || []); | ||
const ret = []; | ||
Object.keys(objArr).forEach(k => { | ||
ret.push(...(objArr[k] || [])); | ||
}); | ||
@@ -267,20 +158,14 @@ return ret; | ||
var AsyncValidationError = /*#__PURE__*/function (_Error) { | ||
_inheritsLoose(AsyncValidationError, _Error); | ||
function AsyncValidationError(errors, fields) { | ||
var _this; | ||
_this = _Error.call(this, 'Async Validation Error') || this; | ||
_this.errors = errors; | ||
_this.fields = fields; | ||
return _this; | ||
class AsyncValidationError extends Error { | ||
constructor(errors, fields) { | ||
super('Async Validation Error'); | ||
this.errors = errors; | ||
this.fields = fields; | ||
} | ||
return AsyncValidationError; | ||
}( /*#__PURE__*/_wrapNativeSuper(Error)); | ||
} | ||
function asyncMap(objArr, option, func, callback, source) { | ||
if (option.first) { | ||
var _pending = new Promise(function (resolve, reject) { | ||
var next = function next(errors) { | ||
const pending = new Promise((resolve, reject) => { | ||
const next = errors => { | ||
callback(errors); | ||
@@ -290,20 +175,16 @@ return errors.length ? reject(new AsyncValidationError(errors, convertFieldsError(errors))) : resolve(source); | ||
var flattenArr = flattenObjArr(objArr); | ||
const flattenArr = flattenObjArr(objArr); | ||
asyncSerialArray(flattenArr, func, next); | ||
}); | ||
_pending["catch"](function (e) { | ||
return e; | ||
}); | ||
return _pending; | ||
pending.catch(e => e); | ||
return pending; | ||
} | ||
var firstFields = option.firstFields === true ? Object.keys(objArr) : option.firstFields || []; | ||
var objArrKeys = Object.keys(objArr); | ||
var objArrLength = objArrKeys.length; | ||
var total = 0; | ||
var results = []; | ||
var pending = new Promise(function (resolve, reject) { | ||
var next = function next(errors) { | ||
const firstFields = option.firstFields === true ? Object.keys(objArr) : option.firstFields || []; | ||
const objArrKeys = Object.keys(objArr); | ||
const objArrLength = objArrKeys.length; | ||
let total = 0; | ||
const results = []; | ||
const pending = new Promise((resolve, reject) => { | ||
const next = errors => { | ||
results.push.apply(results, errors); | ||
@@ -323,4 +204,4 @@ total++; | ||
objArrKeys.forEach(function (key) { | ||
var arr = objArr[key]; | ||
objArrKeys.forEach(key => { | ||
const arr = objArr[key]; | ||
@@ -334,5 +215,3 @@ if (firstFields.indexOf(key) !== -1) { | ||
}); | ||
pending["catch"](function (e) { | ||
return e; | ||
}); | ||
pending.catch(e => e); | ||
return pending; | ||
@@ -346,5 +225,5 @@ } | ||
function getValue(value, path) { | ||
var v = value; | ||
let v = value; | ||
for (var i = 0; i < path.length; i++) { | ||
for (let i = 0; i < path.length; i++) { | ||
if (v == undefined) { | ||
@@ -361,4 +240,4 @@ return v; | ||
function complementError(rule, source) { | ||
return function (oe) { | ||
var fieldValue; | ||
return oe => { | ||
let fieldValue; | ||
@@ -379,3 +258,3 @@ if (rule.fullFields) { | ||
message: typeof oe === 'function' ? oe() : oe, | ||
fieldValue: fieldValue, | ||
fieldValue, | ||
field: oe.field || rule.fullField | ||
@@ -387,8 +266,10 @@ }; | ||
if (source) { | ||
for (var s in source) { | ||
for (const s in source) { | ||
if (source.hasOwnProperty(s)) { | ||
var value = source[s]; | ||
const value = source[s]; | ||
if (typeof value === 'object' && typeof target[s] === 'object') { | ||
target[s] = _extends({}, target[s], value); | ||
target[s] = { ...target[s], | ||
...value | ||
}; | ||
} else { | ||
@@ -404,3 +285,3 @@ target[s] = value; | ||
var required$1 = function required(rule, value, source, errors, options, type) { | ||
const required$1 = (rule, value, source, errors, options, type) => { | ||
if (rule.required && (!source.hasOwnProperty(rule.field) || isEmptyValue(value, type || rule.type))) { | ||
@@ -423,3 +304,3 @@ errors.push(format(options.messages.required, rule.fullField)); | ||
var whitespace = function whitespace(rule, value, source, errors, options) { | ||
const whitespace = (rule, value, source, errors, options) => { | ||
if (/^\s+$/.test(value) || value === '') { | ||
@@ -432,19 +313,24 @@ errors.push(format(options.messages.whitespace, rule.fullField)); | ||
var pattern$2 = { | ||
const pattern$2 = { | ||
// http://emailregex.com/ | ||
email: /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/, | ||
url: new RegExp("^(?!mailto:)(?:(?:http|https|ftp)://|//)(?:\\S+(?::\\S*)?@)?(?:(?:(?:[1-9]\\d?|1\\d\\d|2[01]\\d|22[0-3])(?:\\.(?:1?\\d{1,2}|2[0-4]\\d|25[0-5])){2}(?:\\.(?:[0-9]\\d?|1\\d\\d|2[0-4]\\d|25[0-4]))|(?:(?:[a-z\\u00a1-\\uffff0-9]+-*)*[a-z\\u00a1-\\uffff0-9]+)(?:\\.(?:[a-z\\u00a1-\\uffff0-9]+-*)*[a-z\\u00a1-\\uffff0-9]+)*(?:\\.(?:[a-z\\u00a1-\\uffff]{2,})))|localhost)(?::\\d{2,5})?(?:(/|\\?|#)[^\\s]*)?$", 'i'), | ||
email: /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+\.)+[a-zA-Z\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]{2,}))$/, | ||
url: urlRegex__default['default']({ | ||
exact: true | ||
}), | ||
hex: /^#?([a-f0-9]{6}|[a-f0-9]{3})$/i | ||
}; | ||
var types = { | ||
integer: function integer(value) { | ||
const types = { | ||
integer(value) { | ||
return types.number(value) && parseInt(value, 10) === value; | ||
}, | ||
"float": function float(value) { | ||
float(value) { | ||
return types.number(value) && !types.integer(value); | ||
}, | ||
array: function array(value) { | ||
array(value) { | ||
return Array.isArray(value); | ||
}, | ||
regexp: function regexp(value) { | ||
regexp(value) { | ||
if (value instanceof RegExp) { | ||
@@ -460,6 +346,8 @@ return true; | ||
}, | ||
date: function date(value) { | ||
date(value) { | ||
return typeof value.getTime === 'function' && typeof value.getMonth === 'function' && typeof value.getYear === 'function' && !isNaN(value.getTime()); | ||
}, | ||
number: function number(value) { | ||
number(value) { | ||
if (isNaN(value)) { | ||
@@ -471,20 +359,26 @@ return false; | ||
}, | ||
object: function object(value) { | ||
object(value) { | ||
return typeof value === 'object' && !types.array(value); | ||
}, | ||
method: function method(value) { | ||
method(value) { | ||
return typeof value === 'function'; | ||
}, | ||
email: function email(value) { | ||
return typeof value === 'string' && !!value.match(pattern$2.email) && value.length < 255; | ||
email(value) { | ||
return typeof value === 'string' && !!value.match(pattern$2.email); | ||
}, | ||
url: function url(value) { | ||
return typeof value === 'string' && !!value.match(pattern$2.url); | ||
url(value) { | ||
return typeof value === 'string' && value.length <= 2048 && !!value.match(pattern$2.url); | ||
}, | ||
hex: function hex(value) { | ||
hex(value) { | ||
return typeof value === 'string' && !!value.match(pattern$2.hex); | ||
} | ||
}; | ||
var type$1 = function type(rule, value, source, errors, options) { | ||
const type$1 = (rule, value, source, errors, options) => { | ||
if (rule.required && value === undefined) { | ||
@@ -495,4 +389,4 @@ required$1(rule, value, source, errors, options); | ||
var custom = ['integer', 'float', 'array', 'regexp', 'object', 'method', 'email', 'number', 'date', 'url', 'hex']; | ||
var ruleType = rule.type; | ||
const custom = ['integer', 'float', 'array', 'regexp', 'object', 'method', 'email', 'number', 'date', 'url', 'hex']; | ||
const ruleType = rule.type; | ||
@@ -509,13 +403,13 @@ if (custom.indexOf(ruleType) > -1) { | ||
var range = function range(rule, value, source, errors, options) { | ||
var len = typeof rule.len === 'number'; | ||
var min = typeof rule.min === 'number'; | ||
var max = typeof rule.max === 'number'; // 正则匹配码点范围从U+010000一直到U+10FFFF的文字(补充平面Supplementary Plane) | ||
const range = (rule, value, source, errors, options) => { | ||
const len = typeof rule.len === 'number'; | ||
const min = typeof rule.min === 'number'; | ||
const max = typeof rule.max === 'number'; // 正则匹配码点范围从U+010000一直到U+10FFFF的文字(补充平面Supplementary Plane) | ||
var spRegexp = /[\uD800-\uDBFF][\uDC00-\uDFFF]/g; | ||
var val = value; | ||
var key = null; | ||
var num = typeof value === 'number'; | ||
var str = typeof value === 'string'; | ||
var arr = Array.isArray(value); | ||
const spRegexp = /[\uD800-\uDBFF][\uDC00-\uDFFF]/g; | ||
let val = value; | ||
let key = null; | ||
const num = typeof value === 'number'; | ||
const str = typeof value === 'string'; | ||
const arr = Array.isArray(value); | ||
@@ -559,5 +453,5 @@ if (num) { | ||
var ENUM$1 = 'enum'; | ||
const ENUM$1 = 'enum'; | ||
var enumerable$1 = function enumerable(rule, value, source, errors, options) { | ||
const enumerable$1 = (rule, value, source, errors, options) => { | ||
rule[ENUM$1] = Array.isArray(rule[ENUM$1]) ? rule[ENUM$1] : []; | ||
@@ -570,3 +464,3 @@ | ||
var pattern$1 = function pattern(rule, value, source, errors, options) { | ||
const pattern$1 = (rule, value, source, errors, options) => { | ||
if (rule.pattern) { | ||
@@ -583,3 +477,3 @@ if (rule.pattern instanceof RegExp) { | ||
} else if (typeof rule.pattern === 'string') { | ||
var _pattern = new RegExp(rule.pattern); | ||
const _pattern = new RegExp(rule.pattern); | ||
@@ -595,12 +489,12 @@ if (!_pattern.test(value)) { | ||
required: required$1, | ||
whitespace: whitespace, | ||
whitespace, | ||
type: type$1, | ||
range: range, | ||
"enum": enumerable$1, | ||
range, | ||
enum: enumerable$1, | ||
pattern: pattern$1 | ||
}; | ||
var string = function string(rule, value, callback, source, options) { | ||
var errors = []; | ||
var validate = rule.required || !rule.required && source.hasOwnProperty(rule.field); | ||
const string = (rule, value, callback, source, options) => { | ||
const errors = []; | ||
const validate = rule.required || !rule.required && source.hasOwnProperty(rule.field); | ||
@@ -628,5 +522,5 @@ if (validate) { | ||
var method = function method(rule, value, callback, source, options) { | ||
var errors = []; | ||
var validate = rule.required || !rule.required && source.hasOwnProperty(rule.field); | ||
const method = (rule, value, callback, source, options) => { | ||
const errors = []; | ||
const validate = rule.required || !rule.required && source.hasOwnProperty(rule.field); | ||
@@ -648,5 +542,5 @@ if (validate) { | ||
var number = function number(rule, value, callback, source, options) { | ||
var errors = []; | ||
var validate = rule.required || !rule.required && source.hasOwnProperty(rule.field); | ||
const number = (rule, value, callback, source, options) => { | ||
const errors = []; | ||
const validate = rule.required || !rule.required && source.hasOwnProperty(rule.field); | ||
@@ -673,5 +567,5 @@ if (validate) { | ||
var _boolean = function _boolean(rule, value, callback, source, options) { | ||
var errors = []; | ||
var validate = rule.required || !rule.required && source.hasOwnProperty(rule.field); | ||
const boolean = (rule, value, callback, source, options) => { | ||
const errors = []; | ||
const validate = rule.required || !rule.required && source.hasOwnProperty(rule.field); | ||
@@ -693,5 +587,5 @@ if (validate) { | ||
var regexp = function regexp(rule, value, callback, source, options) { | ||
var errors = []; | ||
var validate = rule.required || !rule.required && source.hasOwnProperty(rule.field); | ||
const regexp = (rule, value, callback, source, options) => { | ||
const errors = []; | ||
const validate = rule.required || !rule.required && source.hasOwnProperty(rule.field); | ||
@@ -713,5 +607,5 @@ if (validate) { | ||
var integer = function integer(rule, value, callback, source, options) { | ||
var errors = []; | ||
var validate = rule.required || !rule.required && source.hasOwnProperty(rule.field); | ||
const integer = (rule, value, callback, source, options) => { | ||
const errors = []; | ||
const validate = rule.required || !rule.required && source.hasOwnProperty(rule.field); | ||
@@ -734,5 +628,5 @@ if (validate) { | ||
var floatFn = function floatFn(rule, value, callback, source, options) { | ||
var errors = []; | ||
var validate = rule.required || !rule.required && source.hasOwnProperty(rule.field); | ||
const floatFn = (rule, value, callback, source, options) => { | ||
const errors = []; | ||
const validate = rule.required || !rule.required && source.hasOwnProperty(rule.field); | ||
@@ -755,5 +649,5 @@ if (validate) { | ||
var array = function array(rule, value, callback, source, options) { | ||
var errors = []; | ||
var validate = rule.required || !rule.required && source.hasOwnProperty(rule.field); | ||
const array = (rule, value, callback, source, options) => { | ||
const errors = []; | ||
const validate = rule.required || !rule.required && source.hasOwnProperty(rule.field); | ||
@@ -776,5 +670,5 @@ if (validate) { | ||
var object = function object(rule, value, callback, source, options) { | ||
var errors = []; | ||
var validate = rule.required || !rule.required && source.hasOwnProperty(rule.field); | ||
const object = (rule, value, callback, source, options) => { | ||
const errors = []; | ||
const validate = rule.required || !rule.required && source.hasOwnProperty(rule.field); | ||
@@ -796,7 +690,7 @@ if (validate) { | ||
var ENUM = 'enum'; | ||
const ENUM = 'enum'; | ||
var enumerable = function enumerable(rule, value, callback, source, options) { | ||
var errors = []; | ||
var validate = rule.required || !rule.required && source.hasOwnProperty(rule.field); | ||
const enumerable = (rule, value, callback, source, options) => { | ||
const errors = []; | ||
const validate = rule.required || !rule.required && source.hasOwnProperty(rule.field); | ||
@@ -818,5 +712,5 @@ if (validate) { | ||
var pattern = function pattern(rule, value, callback, source, options) { | ||
var errors = []; | ||
var validate = rule.required || !rule.required && source.hasOwnProperty(rule.field); | ||
const pattern = (rule, value, callback, source, options) => { | ||
const errors = []; | ||
const validate = rule.required || !rule.required && source.hasOwnProperty(rule.field); | ||
@@ -838,6 +732,6 @@ if (validate) { | ||
var date = function date(rule, value, callback, source, options) { | ||
const date = (rule, value, callback, source, options) => { | ||
// console.log('integer rule called %j', rule); | ||
var errors = []; | ||
var validate = rule.required || !rule.required && source.hasOwnProperty(rule.field); // console.log('validate on %s value', value); | ||
const errors = []; | ||
const validate = rule.required || !rule.required && source.hasOwnProperty(rule.field); // console.log('validate on %s value', value); | ||
@@ -852,3 +746,3 @@ if (validate) { | ||
if (!isEmptyValue(value, 'date')) { | ||
var dateObject; | ||
let dateObject; | ||
@@ -872,5 +766,5 @@ if (value instanceof Date) { | ||
var required = function required(rule, value, callback, source, options) { | ||
var errors = []; | ||
var type = Array.isArray(value) ? 'array' : typeof value; | ||
const required = (rule, value, callback, source, options) => { | ||
const errors = []; | ||
const type = Array.isArray(value) ? 'array' : typeof value; | ||
rules.required(rule, value, source, errors, options, type); | ||
@@ -880,6 +774,6 @@ callback(errors); | ||
var type = function type(rule, value, callback, source, options) { | ||
var ruleType = rule.type; | ||
var errors = []; | ||
var validate = rule.required || !rule.required && source.hasOwnProperty(rule.field); | ||
const type = (rule, value, callback, source, options) => { | ||
const ruleType = rule.type; | ||
const errors = []; | ||
const validate = rule.required || !rule.required && source.hasOwnProperty(rule.field); | ||
@@ -901,5 +795,5 @@ if (validate) { | ||
var any = function any(rule, value, callback, source, options) { | ||
var errors = []; | ||
var validate = rule.required || !rule.required && source.hasOwnProperty(rule.field); | ||
const any = (rule, value, callback, source, options) => { | ||
const errors = []; | ||
const validate = rule.required || !rule.required && source.hasOwnProperty(rule.field); | ||
@@ -918,19 +812,19 @@ if (validate) { | ||
var validators = { | ||
string: string, | ||
method: method, | ||
number: number, | ||
"boolean": _boolean, | ||
regexp: regexp, | ||
integer: integer, | ||
"float": floatFn, | ||
array: array, | ||
object: object, | ||
"enum": enumerable, | ||
pattern: pattern, | ||
date: date, | ||
string, | ||
method, | ||
number, | ||
boolean, | ||
regexp, | ||
integer, | ||
float: floatFn, | ||
array, | ||
object, | ||
enum: enumerable, | ||
pattern, | ||
date, | ||
url: type, | ||
hex: type, | ||
email: type, | ||
required: required, | ||
any: any | ||
required, | ||
any | ||
}; | ||
@@ -940,5 +834,5 @@ | ||
return { | ||
"default": 'Validation error on field %s', | ||
default: 'Validation error on field %s', | ||
required: '%s is required', | ||
"enum": '%s must be one of %s', | ||
enum: '%s must be one of %s', | ||
whitespace: '%s cannot be empty', | ||
@@ -957,5 +851,5 @@ date: { | ||
date: '%s is not a %s', | ||
"boolean": '%s is not a %s', | ||
boolean: '%s is not a %s', | ||
integer: '%s is not an %s', | ||
"float": '%s is not a %s', | ||
float: '%s is not a %s', | ||
regexp: '%s is not a valid %s', | ||
@@ -987,10 +881,12 @@ email: '%s is not a valid %s', | ||
}, | ||
clone: function clone() { | ||
var cloned = JSON.parse(JSON.stringify(this)); | ||
clone() { | ||
const cloned = JSON.parse(JSON.stringify(this)); | ||
cloned.clone = this.clone; | ||
return cloned; | ||
} | ||
}; | ||
} | ||
var messages = newMessages(); | ||
const messages = newMessages(); | ||
@@ -1004,16 +900,23 @@ /** | ||
var Schema = /*#__PURE__*/function () { | ||
class Schema { | ||
// ========================= Static ========================= | ||
// ======================== Instance ======================== | ||
function Schema(descriptor) { | ||
this.rules = null; | ||
this._messages = messages; | ||
static register = function register(type, validator) { | ||
if (typeof validator !== 'function') { | ||
throw new Error('Cannot register a validator by type, validator is not a function'); | ||
} | ||
validators[type] = validator; | ||
}; | ||
static warning = warning; | ||
static messages = messages; | ||
static validators = validators; // ======================== Instance ======================== | ||
rules = null; | ||
_messages = messages; | ||
constructor(descriptor) { | ||
this.define(descriptor); | ||
} | ||
var _proto = Schema.prototype; | ||
_proto.define = function define(rules) { | ||
var _this = this; | ||
define(rules) { | ||
if (!rules) { | ||
@@ -1028,31 +931,21 @@ throw new Error('Cannot configure a schema with no rules'); | ||
this.rules = {}; | ||
Object.keys(rules).forEach(function (name) { | ||
var item = rules[name]; | ||
_this.rules[name] = Array.isArray(item) ? item : [item]; | ||
Object.keys(rules).forEach(name => { | ||
const item = rules[name]; | ||
this.rules[name] = Array.isArray(item) ? item : [item]; | ||
}); | ||
}; | ||
} | ||
_proto.messages = function messages(_messages) { | ||
if (_messages) { | ||
this._messages = deepMerge(newMessages(), _messages); | ||
messages(messages) { | ||
if (messages) { | ||
this._messages = deepMerge(newMessages(), messages); | ||
} | ||
return this._messages; | ||
}; | ||
} | ||
_proto.validate = function validate(source_, o, oc) { | ||
var _this2 = this; | ||
validate(source_, o = {}, oc = () => {}) { | ||
let source = source_; | ||
let options = o; | ||
let callback = oc; | ||
if (o === void 0) { | ||
o = {}; | ||
} | ||
if (oc === void 0) { | ||
oc = function oc() {}; | ||
} | ||
var source = source_; | ||
var options = o; | ||
var callback = oc; | ||
if (typeof options === 'function') { | ||
@@ -1072,10 +965,8 @@ callback = options; | ||
function complete(results) { | ||
var errors = []; | ||
var fields = {}; | ||
let errors = []; | ||
let fields = {}; | ||
function add(e) { | ||
if (Array.isArray(e)) { | ||
var _errors; | ||
errors = (_errors = errors).concat.apply(_errors, e); | ||
errors = errors.concat(...e); | ||
} else { | ||
@@ -1086,3 +977,3 @@ errors.push(e); | ||
for (var i = 0; i < results.length; i++) { | ||
for (let i = 0; i < results.length; i++) { | ||
add(results[i]); | ||
@@ -1100,3 +991,3 @@ } | ||
if (options.messages) { | ||
var messages$1 = this.messages(); | ||
let messages$1 = this.messages(); | ||
@@ -1113,13 +1004,14 @@ if (messages$1 === messages) { | ||
var series = {}; | ||
var keys = options.keys || Object.keys(this.rules); | ||
keys.forEach(function (z) { | ||
var arr = _this2.rules[z]; | ||
var value = source[z]; | ||
arr.forEach(function (r) { | ||
var rule = r; | ||
const series = {}; | ||
const keys = options.keys || Object.keys(this.rules); | ||
keys.forEach(z => { | ||
const arr = this.rules[z]; | ||
let value = source[z]; | ||
arr.forEach(r => { | ||
let rule = r; | ||
if (typeof rule.transform === 'function') { | ||
if (source === source_) { | ||
source = _extends({}, source); | ||
source = { ...source | ||
}; | ||
} | ||
@@ -1135,7 +1027,8 @@ | ||
} else { | ||
rule = _extends({}, rule); | ||
rule = { ...rule | ||
}; | ||
} // Fill validator. Skip if nothing need to validate | ||
rule.validator = _this2.getValidationMethod(rule); | ||
rule.validator = this.getValidationMethod(rule); | ||
@@ -1148,8 +1041,8 @@ if (!rule.validator) { | ||
rule.fullField = rule.fullField || z; | ||
rule.type = _this2.getType(rule); | ||
rule.type = this.getType(rule); | ||
series[z] = series[z] || []; | ||
series[z].push({ | ||
rule: rule, | ||
value: value, | ||
source: source, | ||
rule, | ||
value, | ||
source, | ||
field: z | ||
@@ -1159,6 +1052,6 @@ }); | ||
}); | ||
var errorFields = {}; | ||
return asyncMap(series, options, function (data, doIt) { | ||
var rule = data.rule; | ||
var deep = (rule.type === 'object' || rule.type === 'array') && (typeof rule.fields === 'object' || typeof rule.defaultField === 'object'); | ||
const errorFields = {}; | ||
return asyncMap(series, options, (data, doIt) => { | ||
const rule = data.rule; | ||
let deep = (rule.type === 'object' || rule.type === 'array') && (typeof rule.fields === 'object' || typeof rule.defaultField === 'object'); | ||
deep = deep && (rule.required || !rule.required && data.value); | ||
@@ -1168,15 +1061,11 @@ rule.field = data.field; | ||
function addFullField(key, schema) { | ||
return _extends({}, schema, { | ||
fullField: rule.fullField + "." + key, | ||
fullFields: rule.fullFields ? [].concat(rule.fullFields, [key]) : [key] | ||
}); | ||
return { ...schema, | ||
fullField: `${rule.fullField}.${key}`, | ||
fullFields: rule.fullFields ? [...rule.fullFields, key] : [key] | ||
}; | ||
} | ||
function cb(e) { | ||
if (e === void 0) { | ||
e = []; | ||
} | ||
function cb(e = []) { | ||
let errorList = Array.isArray(e) ? e : [e]; | ||
var errorList = Array.isArray(e) ? e : [e]; | ||
if (!options.suppressWarning && errorList.length) { | ||
@@ -1191,3 +1080,3 @@ Schema.warning('async-validator:', errorList); | ||
var filledErrors = errorList.map(complementError(rule, source)); | ||
let filledErrors = errorList.map(complementError(rule, source)); | ||
@@ -1215,6 +1104,6 @@ if (options.first && filledErrors.length) { | ||
var fieldsSchema = {}; | ||
let fieldsSchema = {}; | ||
if (rule.defaultField) { | ||
Object.keys(data.value).map(function (key) { | ||
Object.keys(data.value).map(key => { | ||
fieldsSchema[key] = rule.defaultField; | ||
@@ -1224,10 +1113,12 @@ }); | ||
fieldsSchema = _extends({}, fieldsSchema, data.rule.fields); | ||
var paredFieldsSchema = {}; | ||
Object.keys(fieldsSchema).forEach(function (field) { | ||
var fieldSchema = fieldsSchema[field]; | ||
var fieldSchemaList = Array.isArray(fieldSchema) ? fieldSchema : [fieldSchema]; | ||
fieldsSchema = { ...fieldsSchema, | ||
...data.rule.fields | ||
}; | ||
const paredFieldsSchema = {}; | ||
Object.keys(fieldsSchema).forEach(field => { | ||
const fieldSchema = fieldsSchema[field]; | ||
const fieldSchemaList = Array.isArray(fieldSchema) ? fieldSchema : [fieldSchema]; | ||
paredFieldsSchema[field] = fieldSchemaList.map(addFullField.bind(null, field)); | ||
}); | ||
var schema = new Schema(paredFieldsSchema); | ||
const schema = new Schema(paredFieldsSchema); | ||
schema.messages(options.messages); | ||
@@ -1240,11 +1131,11 @@ | ||
schema.validate(data.value, data.rule.options || options, function (errs) { | ||
var finalErrors = []; | ||
schema.validate(data.value, data.rule.options || options, errs => { | ||
const finalErrors = []; | ||
if (filledErrors && filledErrors.length) { | ||
finalErrors.push.apply(finalErrors, filledErrors); | ||
finalErrors.push(...filledErrors); | ||
} | ||
if (errs && errs.length) { | ||
finalErrors.push.apply(finalErrors, errs); | ||
finalErrors.push(...errs); | ||
} | ||
@@ -1257,3 +1148,3 @@ | ||
var res; | ||
let res; | ||
@@ -1268,3 +1159,3 @@ if (rule.asyncValidator) { | ||
} else if (res === false) { | ||
cb(typeof rule.message === 'function' ? rule.message(rule.fullField || rule.field) : rule.message || (rule.fullField || rule.field) + " fails"); | ||
cb(typeof rule.message === 'function' ? rule.message(rule.fullField || rule.field) : rule.message || `${rule.fullField || rule.field} fails`); | ||
} else if (res instanceof Array) { | ||
@@ -1278,14 +1169,10 @@ cb(res); | ||
if (res && res.then) { | ||
res.then(function () { | ||
return cb(); | ||
}, function (e) { | ||
return cb(e); | ||
}); | ||
res.then(() => cb(), e => cb(e)); | ||
} | ||
}, function (results) { | ||
}, results => { | ||
complete(results); | ||
}, source); | ||
}; | ||
} | ||
_proto.getType = function getType(rule) { | ||
getType(rule) { | ||
if (rule.type === undefined && rule.pattern instanceof RegExp) { | ||
@@ -1300,5 +1187,5 @@ rule.type = 'pattern'; | ||
return rule.type || 'string'; | ||
}; | ||
} | ||
_proto.getValidationMethod = function getValidationMethod(rule) { | ||
getValidationMethod(rule) { | ||
if (typeof rule.validator === 'function') { | ||
@@ -1308,4 +1195,4 @@ return rule.validator; | ||
var keys = Object.keys(rule); | ||
var messageIndex = keys.indexOf('message'); | ||
const keys = Object.keys(rule); | ||
const messageIndex = keys.indexOf('message'); | ||
@@ -1321,20 +1208,7 @@ if (messageIndex !== -1) { | ||
return validators[this.getType(rule)] || undefined; | ||
}; | ||
return Schema; | ||
}(); | ||
Schema.register = function register(type, validator) { | ||
if (typeof validator !== 'function') { | ||
throw new Error('Cannot register a validator by type, validator is not a function'); | ||
} | ||
validators[type] = validator; | ||
}; | ||
} | ||
Schema.warning = warning; | ||
Schema.messages = messages; | ||
Schema.validators = validators; | ||
exports['default'] = Schema; | ||
//# sourceMappingURL=index.js.map |
@@ -1,120 +0,11 @@ | ||
function _extends() { | ||
_extends = Object.assign || function (target) { | ||
for (var i = 1; i < arguments.length; i++) { | ||
var source = arguments[i]; | ||
import urlRegex from 'url-regex'; | ||
for (var key in source) { | ||
if (Object.prototype.hasOwnProperty.call(source, key)) { | ||
target[key] = source[key]; | ||
} | ||
} | ||
} | ||
return target; | ||
}; | ||
return _extends.apply(this, arguments); | ||
} | ||
function _inheritsLoose(subClass, superClass) { | ||
subClass.prototype = Object.create(superClass.prototype); | ||
subClass.prototype.constructor = subClass; | ||
_setPrototypeOf(subClass, superClass); | ||
} | ||
function _getPrototypeOf(o) { | ||
_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { | ||
return o.__proto__ || Object.getPrototypeOf(o); | ||
}; | ||
return _getPrototypeOf(o); | ||
} | ||
function _setPrototypeOf(o, p) { | ||
_setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { | ||
o.__proto__ = p; | ||
return o; | ||
}; | ||
return _setPrototypeOf(o, p); | ||
} | ||
function _isNativeReflectConstruct() { | ||
if (typeof Reflect === "undefined" || !Reflect.construct) return false; | ||
if (Reflect.construct.sham) return false; | ||
if (typeof Proxy === "function") return true; | ||
try { | ||
Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); | ||
return true; | ||
} catch (e) { | ||
return false; | ||
} | ||
} | ||
function _construct(Parent, args, Class) { | ||
if (_isNativeReflectConstruct()) { | ||
_construct = Reflect.construct; | ||
} else { | ||
_construct = function _construct(Parent, args, Class) { | ||
var a = [null]; | ||
a.push.apply(a, args); | ||
var Constructor = Function.bind.apply(Parent, a); | ||
var instance = new Constructor(); | ||
if (Class) _setPrototypeOf(instance, Class.prototype); | ||
return instance; | ||
}; | ||
} | ||
return _construct.apply(null, arguments); | ||
} | ||
function _isNativeFunction(fn) { | ||
return Function.toString.call(fn).indexOf("[native code]") !== -1; | ||
} | ||
function _wrapNativeSuper(Class) { | ||
var _cache = typeof Map === "function" ? new Map() : undefined; | ||
_wrapNativeSuper = function _wrapNativeSuper(Class) { | ||
if (Class === null || !_isNativeFunction(Class)) return Class; | ||
if (typeof Class !== "function") { | ||
throw new TypeError("Super expression must either be null or a function"); | ||
} | ||
if (typeof _cache !== "undefined") { | ||
if (_cache.has(Class)) return _cache.get(Class); | ||
_cache.set(Class, Wrapper); | ||
} | ||
function Wrapper() { | ||
return _construct(Class, arguments, _getPrototypeOf(this).constructor); | ||
} | ||
Wrapper.prototype = Object.create(Class.prototype, { | ||
constructor: { | ||
value: Wrapper, | ||
enumerable: false, | ||
writable: true, | ||
configurable: true | ||
} | ||
}); | ||
return _setPrototypeOf(Wrapper, Class); | ||
}; | ||
return _wrapNativeSuper(Class); | ||
} | ||
/* eslint no-console:0 */ | ||
var formatRegExp = /%[sdj%]/g; | ||
var warning = function warning() {}; // don't print warning message when in production env or node runtime | ||
const formatRegExp = /%[sdj%]/g; | ||
let warning = () => {}; // don't print warning message when in production env or node runtime | ||
if (typeof process !== 'undefined' && process.env && process.env.NODE_ENV !== 'production' && typeof window !== 'undefined' && typeof document !== 'undefined') { | ||
warning = function warning(type, errors) { | ||
warning = (type, errors) => { | ||
if (typeof console !== 'undefined' && console.warn && typeof ASYNC_VALIDATOR_NO_WARNING === 'undefined') { | ||
if (errors.every(function (e) { | ||
return typeof e === 'string'; | ||
})) { | ||
if (errors.every(e => typeof e === 'string')) { | ||
console.warn(type, errors); | ||
@@ -128,5 +19,5 @@ } | ||
if (!errors || !errors.length) return null; | ||
var fields = {}; | ||
errors.forEach(function (error) { | ||
var field = error.field; | ||
const fields = {}; | ||
errors.forEach(error => { | ||
const field = error.field; | ||
fields[field] = fields[field] || []; | ||
@@ -137,10 +28,6 @@ fields[field].push(error); | ||
} | ||
function format(template) { | ||
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { | ||
args[_key - 1] = arguments[_key]; | ||
} | ||
function format(template, ...args) { | ||
let i = 0; | ||
const len = args.length; | ||
var i = 0; | ||
var len = args.length; | ||
if (typeof template === 'function') { | ||
@@ -151,3 +38,3 @@ return template.apply(null, args); | ||
if (typeof template === 'string') { | ||
var str = template.replace(formatRegExp, function (x) { | ||
let str = template.replace(formatRegExp, x => { | ||
if (x === '%%') { | ||
@@ -208,8 +95,8 @@ return '%'; | ||
function asyncParallelArray(arr, func, callback) { | ||
var results = []; | ||
var total = 0; | ||
var arrLength = arr.length; | ||
const results = []; | ||
let total = 0; | ||
const arrLength = arr.length; | ||
function count(errors) { | ||
results.push.apply(results, errors || []); | ||
results.push(...(errors || [])); | ||
total++; | ||
@@ -222,3 +109,3 @@ | ||
arr.forEach(function (a) { | ||
arr.forEach(a => { | ||
func(a, count); | ||
@@ -229,4 +116,4 @@ }); | ||
function asyncSerialArray(arr, func, callback) { | ||
var index = 0; | ||
var arrLength = arr.length; | ||
let index = 0; | ||
const arrLength = arr.length; | ||
@@ -239,3 +126,3 @@ function next(errors) { | ||
var original = index; | ||
const original = index; | ||
index = index + 1; | ||
@@ -254,5 +141,5 @@ | ||
function flattenObjArr(objArr) { | ||
var ret = []; | ||
Object.keys(objArr).forEach(function (k) { | ||
ret.push.apply(ret, objArr[k] || []); | ||
const ret = []; | ||
Object.keys(objArr).forEach(k => { | ||
ret.push(...(objArr[k] || [])); | ||
}); | ||
@@ -262,20 +149,14 @@ return ret; | ||
var AsyncValidationError = /*#__PURE__*/function (_Error) { | ||
_inheritsLoose(AsyncValidationError, _Error); | ||
function AsyncValidationError(errors, fields) { | ||
var _this; | ||
_this = _Error.call(this, 'Async Validation Error') || this; | ||
_this.errors = errors; | ||
_this.fields = fields; | ||
return _this; | ||
class AsyncValidationError extends Error { | ||
constructor(errors, fields) { | ||
super('Async Validation Error'); | ||
this.errors = errors; | ||
this.fields = fields; | ||
} | ||
return AsyncValidationError; | ||
}( /*#__PURE__*/_wrapNativeSuper(Error)); | ||
} | ||
function asyncMap(objArr, option, func, callback, source) { | ||
if (option.first) { | ||
var _pending = new Promise(function (resolve, reject) { | ||
var next = function next(errors) { | ||
const pending = new Promise((resolve, reject) => { | ||
const next = errors => { | ||
callback(errors); | ||
@@ -285,20 +166,16 @@ return errors.length ? reject(new AsyncValidationError(errors, convertFieldsError(errors))) : resolve(source); | ||
var flattenArr = flattenObjArr(objArr); | ||
const flattenArr = flattenObjArr(objArr); | ||
asyncSerialArray(flattenArr, func, next); | ||
}); | ||
_pending["catch"](function (e) { | ||
return e; | ||
}); | ||
return _pending; | ||
pending.catch(e => e); | ||
return pending; | ||
} | ||
var firstFields = option.firstFields === true ? Object.keys(objArr) : option.firstFields || []; | ||
var objArrKeys = Object.keys(objArr); | ||
var objArrLength = objArrKeys.length; | ||
var total = 0; | ||
var results = []; | ||
var pending = new Promise(function (resolve, reject) { | ||
var next = function next(errors) { | ||
const firstFields = option.firstFields === true ? Object.keys(objArr) : option.firstFields || []; | ||
const objArrKeys = Object.keys(objArr); | ||
const objArrLength = objArrKeys.length; | ||
let total = 0; | ||
const results = []; | ||
const pending = new Promise((resolve, reject) => { | ||
const next = errors => { | ||
results.push.apply(results, errors); | ||
@@ -318,4 +195,4 @@ total++; | ||
objArrKeys.forEach(function (key) { | ||
var arr = objArr[key]; | ||
objArrKeys.forEach(key => { | ||
const arr = objArr[key]; | ||
@@ -329,5 +206,3 @@ if (firstFields.indexOf(key) !== -1) { | ||
}); | ||
pending["catch"](function (e) { | ||
return e; | ||
}); | ||
pending.catch(e => e); | ||
return pending; | ||
@@ -341,5 +216,5 @@ } | ||
function getValue(value, path) { | ||
var v = value; | ||
let v = value; | ||
for (var i = 0; i < path.length; i++) { | ||
for (let i = 0; i < path.length; i++) { | ||
if (v == undefined) { | ||
@@ -356,4 +231,4 @@ return v; | ||
function complementError(rule, source) { | ||
return function (oe) { | ||
var fieldValue; | ||
return oe => { | ||
let fieldValue; | ||
@@ -374,3 +249,3 @@ if (rule.fullFields) { | ||
message: typeof oe === 'function' ? oe() : oe, | ||
fieldValue: fieldValue, | ||
fieldValue, | ||
field: oe.field || rule.fullField | ||
@@ -382,8 +257,10 @@ }; | ||
if (source) { | ||
for (var s in source) { | ||
for (const s in source) { | ||
if (source.hasOwnProperty(s)) { | ||
var value = source[s]; | ||
const value = source[s]; | ||
if (typeof value === 'object' && typeof target[s] === 'object') { | ||
target[s] = _extends({}, target[s], value); | ||
target[s] = { ...target[s], | ||
...value | ||
}; | ||
} else { | ||
@@ -399,3 +276,3 @@ target[s] = value; | ||
var required$1 = function required(rule, value, source, errors, options, type) { | ||
const required$1 = (rule, value, source, errors, options, type) => { | ||
if (rule.required && (!source.hasOwnProperty(rule.field) || isEmptyValue(value, type || rule.type))) { | ||
@@ -418,3 +295,3 @@ errors.push(format(options.messages.required, rule.fullField)); | ||
var whitespace = function whitespace(rule, value, source, errors, options) { | ||
const whitespace = (rule, value, source, errors, options) => { | ||
if (/^\s+$/.test(value) || value === '') { | ||
@@ -427,19 +304,24 @@ errors.push(format(options.messages.whitespace, rule.fullField)); | ||
var pattern$2 = { | ||
const pattern$2 = { | ||
// http://emailregex.com/ | ||
email: /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/, | ||
url: new RegExp("^(?!mailto:)(?:(?:http|https|ftp)://|//)(?:\\S+(?::\\S*)?@)?(?:(?:(?:[1-9]\\d?|1\\d\\d|2[01]\\d|22[0-3])(?:\\.(?:1?\\d{1,2}|2[0-4]\\d|25[0-5])){2}(?:\\.(?:[0-9]\\d?|1\\d\\d|2[0-4]\\d|25[0-4]))|(?:(?:[a-z\\u00a1-\\uffff0-9]+-*)*[a-z\\u00a1-\\uffff0-9]+)(?:\\.(?:[a-z\\u00a1-\\uffff0-9]+-*)*[a-z\\u00a1-\\uffff0-9]+)*(?:\\.(?:[a-z\\u00a1-\\uffff]{2,})))|localhost)(?::\\d{2,5})?(?:(/|\\?|#)[^\\s]*)?$", 'i'), | ||
email: /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+\.)+[a-zA-Z\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]{2,}))$/, | ||
url: urlRegex({ | ||
exact: true | ||
}), | ||
hex: /^#?([a-f0-9]{6}|[a-f0-9]{3})$/i | ||
}; | ||
var types = { | ||
integer: function integer(value) { | ||
const types = { | ||
integer(value) { | ||
return types.number(value) && parseInt(value, 10) === value; | ||
}, | ||
"float": function float(value) { | ||
float(value) { | ||
return types.number(value) && !types.integer(value); | ||
}, | ||
array: function array(value) { | ||
array(value) { | ||
return Array.isArray(value); | ||
}, | ||
regexp: function regexp(value) { | ||
regexp(value) { | ||
if (value instanceof RegExp) { | ||
@@ -455,6 +337,8 @@ return true; | ||
}, | ||
date: function date(value) { | ||
date(value) { | ||
return typeof value.getTime === 'function' && typeof value.getMonth === 'function' && typeof value.getYear === 'function' && !isNaN(value.getTime()); | ||
}, | ||
number: function number(value) { | ||
number(value) { | ||
if (isNaN(value)) { | ||
@@ -466,20 +350,26 @@ return false; | ||
}, | ||
object: function object(value) { | ||
object(value) { | ||
return typeof value === 'object' && !types.array(value); | ||
}, | ||
method: function method(value) { | ||
method(value) { | ||
return typeof value === 'function'; | ||
}, | ||
email: function email(value) { | ||
return typeof value === 'string' && !!value.match(pattern$2.email) && value.length < 255; | ||
email(value) { | ||
return typeof value === 'string' && !!value.match(pattern$2.email); | ||
}, | ||
url: function url(value) { | ||
return typeof value === 'string' && !!value.match(pattern$2.url); | ||
url(value) { | ||
return typeof value === 'string' && value.length <= 2048 && !!value.match(pattern$2.url); | ||
}, | ||
hex: function hex(value) { | ||
hex(value) { | ||
return typeof value === 'string' && !!value.match(pattern$2.hex); | ||
} | ||
}; | ||
var type$1 = function type(rule, value, source, errors, options) { | ||
const type$1 = (rule, value, source, errors, options) => { | ||
if (rule.required && value === undefined) { | ||
@@ -490,4 +380,4 @@ required$1(rule, value, source, errors, options); | ||
var custom = ['integer', 'float', 'array', 'regexp', 'object', 'method', 'email', 'number', 'date', 'url', 'hex']; | ||
var ruleType = rule.type; | ||
const custom = ['integer', 'float', 'array', 'regexp', 'object', 'method', 'email', 'number', 'date', 'url', 'hex']; | ||
const ruleType = rule.type; | ||
@@ -504,13 +394,13 @@ if (custom.indexOf(ruleType) > -1) { | ||
var range = function range(rule, value, source, errors, options) { | ||
var len = typeof rule.len === 'number'; | ||
var min = typeof rule.min === 'number'; | ||
var max = typeof rule.max === 'number'; // 正则匹配码点范围从U+010000一直到U+10FFFF的文字(补充平面Supplementary Plane) | ||
const range = (rule, value, source, errors, options) => { | ||
const len = typeof rule.len === 'number'; | ||
const min = typeof rule.min === 'number'; | ||
const max = typeof rule.max === 'number'; // 正则匹配码点范围从U+010000一直到U+10FFFF的文字(补充平面Supplementary Plane) | ||
var spRegexp = /[\uD800-\uDBFF][\uDC00-\uDFFF]/g; | ||
var val = value; | ||
var key = null; | ||
var num = typeof value === 'number'; | ||
var str = typeof value === 'string'; | ||
var arr = Array.isArray(value); | ||
const spRegexp = /[\uD800-\uDBFF][\uDC00-\uDFFF]/g; | ||
let val = value; | ||
let key = null; | ||
const num = typeof value === 'number'; | ||
const str = typeof value === 'string'; | ||
const arr = Array.isArray(value); | ||
@@ -554,5 +444,5 @@ if (num) { | ||
var ENUM$1 = 'enum'; | ||
const ENUM$1 = 'enum'; | ||
var enumerable$1 = function enumerable(rule, value, source, errors, options) { | ||
const enumerable$1 = (rule, value, source, errors, options) => { | ||
rule[ENUM$1] = Array.isArray(rule[ENUM$1]) ? rule[ENUM$1] : []; | ||
@@ -565,3 +455,3 @@ | ||
var pattern$1 = function pattern(rule, value, source, errors, options) { | ||
const pattern$1 = (rule, value, source, errors, options) => { | ||
if (rule.pattern) { | ||
@@ -578,3 +468,3 @@ if (rule.pattern instanceof RegExp) { | ||
} else if (typeof rule.pattern === 'string') { | ||
var _pattern = new RegExp(rule.pattern); | ||
const _pattern = new RegExp(rule.pattern); | ||
@@ -590,12 +480,12 @@ if (!_pattern.test(value)) { | ||
required: required$1, | ||
whitespace: whitespace, | ||
whitespace, | ||
type: type$1, | ||
range: range, | ||
"enum": enumerable$1, | ||
range, | ||
enum: enumerable$1, | ||
pattern: pattern$1 | ||
}; | ||
var string = function string(rule, value, callback, source, options) { | ||
var errors = []; | ||
var validate = rule.required || !rule.required && source.hasOwnProperty(rule.field); | ||
const string = (rule, value, callback, source, options) => { | ||
const errors = []; | ||
const validate = rule.required || !rule.required && source.hasOwnProperty(rule.field); | ||
@@ -623,5 +513,5 @@ if (validate) { | ||
var method = function method(rule, value, callback, source, options) { | ||
var errors = []; | ||
var validate = rule.required || !rule.required && source.hasOwnProperty(rule.field); | ||
const method = (rule, value, callback, source, options) => { | ||
const errors = []; | ||
const validate = rule.required || !rule.required && source.hasOwnProperty(rule.field); | ||
@@ -643,5 +533,5 @@ if (validate) { | ||
var number = function number(rule, value, callback, source, options) { | ||
var errors = []; | ||
var validate = rule.required || !rule.required && source.hasOwnProperty(rule.field); | ||
const number = (rule, value, callback, source, options) => { | ||
const errors = []; | ||
const validate = rule.required || !rule.required && source.hasOwnProperty(rule.field); | ||
@@ -668,5 +558,5 @@ if (validate) { | ||
var _boolean = function _boolean(rule, value, callback, source, options) { | ||
var errors = []; | ||
var validate = rule.required || !rule.required && source.hasOwnProperty(rule.field); | ||
const boolean = (rule, value, callback, source, options) => { | ||
const errors = []; | ||
const validate = rule.required || !rule.required && source.hasOwnProperty(rule.field); | ||
@@ -688,5 +578,5 @@ if (validate) { | ||
var regexp = function regexp(rule, value, callback, source, options) { | ||
var errors = []; | ||
var validate = rule.required || !rule.required && source.hasOwnProperty(rule.field); | ||
const regexp = (rule, value, callback, source, options) => { | ||
const errors = []; | ||
const validate = rule.required || !rule.required && source.hasOwnProperty(rule.field); | ||
@@ -708,5 +598,5 @@ if (validate) { | ||
var integer = function integer(rule, value, callback, source, options) { | ||
var errors = []; | ||
var validate = rule.required || !rule.required && source.hasOwnProperty(rule.field); | ||
const integer = (rule, value, callback, source, options) => { | ||
const errors = []; | ||
const validate = rule.required || !rule.required && source.hasOwnProperty(rule.field); | ||
@@ -729,5 +619,5 @@ if (validate) { | ||
var floatFn = function floatFn(rule, value, callback, source, options) { | ||
var errors = []; | ||
var validate = rule.required || !rule.required && source.hasOwnProperty(rule.field); | ||
const floatFn = (rule, value, callback, source, options) => { | ||
const errors = []; | ||
const validate = rule.required || !rule.required && source.hasOwnProperty(rule.field); | ||
@@ -750,5 +640,5 @@ if (validate) { | ||
var array = function array(rule, value, callback, source, options) { | ||
var errors = []; | ||
var validate = rule.required || !rule.required && source.hasOwnProperty(rule.field); | ||
const array = (rule, value, callback, source, options) => { | ||
const errors = []; | ||
const validate = rule.required || !rule.required && source.hasOwnProperty(rule.field); | ||
@@ -771,5 +661,5 @@ if (validate) { | ||
var object = function object(rule, value, callback, source, options) { | ||
var errors = []; | ||
var validate = rule.required || !rule.required && source.hasOwnProperty(rule.field); | ||
const object = (rule, value, callback, source, options) => { | ||
const errors = []; | ||
const validate = rule.required || !rule.required && source.hasOwnProperty(rule.field); | ||
@@ -791,7 +681,7 @@ if (validate) { | ||
var ENUM = 'enum'; | ||
const ENUM = 'enum'; | ||
var enumerable = function enumerable(rule, value, callback, source, options) { | ||
var errors = []; | ||
var validate = rule.required || !rule.required && source.hasOwnProperty(rule.field); | ||
const enumerable = (rule, value, callback, source, options) => { | ||
const errors = []; | ||
const validate = rule.required || !rule.required && source.hasOwnProperty(rule.field); | ||
@@ -813,5 +703,5 @@ if (validate) { | ||
var pattern = function pattern(rule, value, callback, source, options) { | ||
var errors = []; | ||
var validate = rule.required || !rule.required && source.hasOwnProperty(rule.field); | ||
const pattern = (rule, value, callback, source, options) => { | ||
const errors = []; | ||
const validate = rule.required || !rule.required && source.hasOwnProperty(rule.field); | ||
@@ -833,6 +723,6 @@ if (validate) { | ||
var date = function date(rule, value, callback, source, options) { | ||
const date = (rule, value, callback, source, options) => { | ||
// console.log('integer rule called %j', rule); | ||
var errors = []; | ||
var validate = rule.required || !rule.required && source.hasOwnProperty(rule.field); // console.log('validate on %s value', value); | ||
const errors = []; | ||
const validate = rule.required || !rule.required && source.hasOwnProperty(rule.field); // console.log('validate on %s value', value); | ||
@@ -847,3 +737,3 @@ if (validate) { | ||
if (!isEmptyValue(value, 'date')) { | ||
var dateObject; | ||
let dateObject; | ||
@@ -867,5 +757,5 @@ if (value instanceof Date) { | ||
var required = function required(rule, value, callback, source, options) { | ||
var errors = []; | ||
var type = Array.isArray(value) ? 'array' : typeof value; | ||
const required = (rule, value, callback, source, options) => { | ||
const errors = []; | ||
const type = Array.isArray(value) ? 'array' : typeof value; | ||
rules.required(rule, value, source, errors, options, type); | ||
@@ -875,6 +765,6 @@ callback(errors); | ||
var type = function type(rule, value, callback, source, options) { | ||
var ruleType = rule.type; | ||
var errors = []; | ||
var validate = rule.required || !rule.required && source.hasOwnProperty(rule.field); | ||
const type = (rule, value, callback, source, options) => { | ||
const ruleType = rule.type; | ||
const errors = []; | ||
const validate = rule.required || !rule.required && source.hasOwnProperty(rule.field); | ||
@@ -896,5 +786,5 @@ if (validate) { | ||
var any = function any(rule, value, callback, source, options) { | ||
var errors = []; | ||
var validate = rule.required || !rule.required && source.hasOwnProperty(rule.field); | ||
const any = (rule, value, callback, source, options) => { | ||
const errors = []; | ||
const validate = rule.required || !rule.required && source.hasOwnProperty(rule.field); | ||
@@ -913,19 +803,19 @@ if (validate) { | ||
var validators = { | ||
string: string, | ||
method: method, | ||
number: number, | ||
"boolean": _boolean, | ||
regexp: regexp, | ||
integer: integer, | ||
"float": floatFn, | ||
array: array, | ||
object: object, | ||
"enum": enumerable, | ||
pattern: pattern, | ||
date: date, | ||
string, | ||
method, | ||
number, | ||
boolean, | ||
regexp, | ||
integer, | ||
float: floatFn, | ||
array, | ||
object, | ||
enum: enumerable, | ||
pattern, | ||
date, | ||
url: type, | ||
hex: type, | ||
email: type, | ||
required: required, | ||
any: any | ||
required, | ||
any | ||
}; | ||
@@ -935,5 +825,5 @@ | ||
return { | ||
"default": 'Validation error on field %s', | ||
default: 'Validation error on field %s', | ||
required: '%s is required', | ||
"enum": '%s must be one of %s', | ||
enum: '%s must be one of %s', | ||
whitespace: '%s cannot be empty', | ||
@@ -952,5 +842,5 @@ date: { | ||
date: '%s is not a %s', | ||
"boolean": '%s is not a %s', | ||
boolean: '%s is not a %s', | ||
integer: '%s is not an %s', | ||
"float": '%s is not a %s', | ||
float: '%s is not a %s', | ||
regexp: '%s is not a valid %s', | ||
@@ -982,10 +872,12 @@ email: '%s is not a valid %s', | ||
}, | ||
clone: function clone() { | ||
var cloned = JSON.parse(JSON.stringify(this)); | ||
clone() { | ||
const cloned = JSON.parse(JSON.stringify(this)); | ||
cloned.clone = this.clone; | ||
return cloned; | ||
} | ||
}; | ||
} | ||
var messages = newMessages(); | ||
const messages = newMessages(); | ||
@@ -999,16 +891,23 @@ /** | ||
var Schema = /*#__PURE__*/function () { | ||
class Schema { | ||
// ========================= Static ========================= | ||
// ======================== Instance ======================== | ||
function Schema(descriptor) { | ||
this.rules = null; | ||
this._messages = messages; | ||
static register = function register(type, validator) { | ||
if (typeof validator !== 'function') { | ||
throw new Error('Cannot register a validator by type, validator is not a function'); | ||
} | ||
validators[type] = validator; | ||
}; | ||
static warning = warning; | ||
static messages = messages; | ||
static validators = validators; // ======================== Instance ======================== | ||
rules = null; | ||
_messages = messages; | ||
constructor(descriptor) { | ||
this.define(descriptor); | ||
} | ||
var _proto = Schema.prototype; | ||
_proto.define = function define(rules) { | ||
var _this = this; | ||
define(rules) { | ||
if (!rules) { | ||
@@ -1023,31 +922,21 @@ throw new Error('Cannot configure a schema with no rules'); | ||
this.rules = {}; | ||
Object.keys(rules).forEach(function (name) { | ||
var item = rules[name]; | ||
_this.rules[name] = Array.isArray(item) ? item : [item]; | ||
Object.keys(rules).forEach(name => { | ||
const item = rules[name]; | ||
this.rules[name] = Array.isArray(item) ? item : [item]; | ||
}); | ||
}; | ||
} | ||
_proto.messages = function messages(_messages) { | ||
if (_messages) { | ||
this._messages = deepMerge(newMessages(), _messages); | ||
messages(messages) { | ||
if (messages) { | ||
this._messages = deepMerge(newMessages(), messages); | ||
} | ||
return this._messages; | ||
}; | ||
} | ||
_proto.validate = function validate(source_, o, oc) { | ||
var _this2 = this; | ||
validate(source_, o = {}, oc = () => {}) { | ||
let source = source_; | ||
let options = o; | ||
let callback = oc; | ||
if (o === void 0) { | ||
o = {}; | ||
} | ||
if (oc === void 0) { | ||
oc = function oc() {}; | ||
} | ||
var source = source_; | ||
var options = o; | ||
var callback = oc; | ||
if (typeof options === 'function') { | ||
@@ -1067,10 +956,8 @@ callback = options; | ||
function complete(results) { | ||
var errors = []; | ||
var fields = {}; | ||
let errors = []; | ||
let fields = {}; | ||
function add(e) { | ||
if (Array.isArray(e)) { | ||
var _errors; | ||
errors = (_errors = errors).concat.apply(_errors, e); | ||
errors = errors.concat(...e); | ||
} else { | ||
@@ -1081,3 +968,3 @@ errors.push(e); | ||
for (var i = 0; i < results.length; i++) { | ||
for (let i = 0; i < results.length; i++) { | ||
add(results[i]); | ||
@@ -1095,3 +982,3 @@ } | ||
if (options.messages) { | ||
var messages$1 = this.messages(); | ||
let messages$1 = this.messages(); | ||
@@ -1108,13 +995,14 @@ if (messages$1 === messages) { | ||
var series = {}; | ||
var keys = options.keys || Object.keys(this.rules); | ||
keys.forEach(function (z) { | ||
var arr = _this2.rules[z]; | ||
var value = source[z]; | ||
arr.forEach(function (r) { | ||
var rule = r; | ||
const series = {}; | ||
const keys = options.keys || Object.keys(this.rules); | ||
keys.forEach(z => { | ||
const arr = this.rules[z]; | ||
let value = source[z]; | ||
arr.forEach(r => { | ||
let rule = r; | ||
if (typeof rule.transform === 'function') { | ||
if (source === source_) { | ||
source = _extends({}, source); | ||
source = { ...source | ||
}; | ||
} | ||
@@ -1130,7 +1018,8 @@ | ||
} else { | ||
rule = _extends({}, rule); | ||
rule = { ...rule | ||
}; | ||
} // Fill validator. Skip if nothing need to validate | ||
rule.validator = _this2.getValidationMethod(rule); | ||
rule.validator = this.getValidationMethod(rule); | ||
@@ -1143,8 +1032,8 @@ if (!rule.validator) { | ||
rule.fullField = rule.fullField || z; | ||
rule.type = _this2.getType(rule); | ||
rule.type = this.getType(rule); | ||
series[z] = series[z] || []; | ||
series[z].push({ | ||
rule: rule, | ||
value: value, | ||
source: source, | ||
rule, | ||
value, | ||
source, | ||
field: z | ||
@@ -1154,6 +1043,6 @@ }); | ||
}); | ||
var errorFields = {}; | ||
return asyncMap(series, options, function (data, doIt) { | ||
var rule = data.rule; | ||
var deep = (rule.type === 'object' || rule.type === 'array') && (typeof rule.fields === 'object' || typeof rule.defaultField === 'object'); | ||
const errorFields = {}; | ||
return asyncMap(series, options, (data, doIt) => { | ||
const rule = data.rule; | ||
let deep = (rule.type === 'object' || rule.type === 'array') && (typeof rule.fields === 'object' || typeof rule.defaultField === 'object'); | ||
deep = deep && (rule.required || !rule.required && data.value); | ||
@@ -1163,15 +1052,11 @@ rule.field = data.field; | ||
function addFullField(key, schema) { | ||
return _extends({}, schema, { | ||
fullField: rule.fullField + "." + key, | ||
fullFields: rule.fullFields ? [].concat(rule.fullFields, [key]) : [key] | ||
}); | ||
return { ...schema, | ||
fullField: `${rule.fullField}.${key}`, | ||
fullFields: rule.fullFields ? [...rule.fullFields, key] : [key] | ||
}; | ||
} | ||
function cb(e) { | ||
if (e === void 0) { | ||
e = []; | ||
} | ||
function cb(e = []) { | ||
let errorList = Array.isArray(e) ? e : [e]; | ||
var errorList = Array.isArray(e) ? e : [e]; | ||
if (!options.suppressWarning && errorList.length) { | ||
@@ -1186,3 +1071,3 @@ Schema.warning('async-validator:', errorList); | ||
var filledErrors = errorList.map(complementError(rule, source)); | ||
let filledErrors = errorList.map(complementError(rule, source)); | ||
@@ -1210,6 +1095,6 @@ if (options.first && filledErrors.length) { | ||
var fieldsSchema = {}; | ||
let fieldsSchema = {}; | ||
if (rule.defaultField) { | ||
Object.keys(data.value).map(function (key) { | ||
Object.keys(data.value).map(key => { | ||
fieldsSchema[key] = rule.defaultField; | ||
@@ -1219,10 +1104,12 @@ }); | ||
fieldsSchema = _extends({}, fieldsSchema, data.rule.fields); | ||
var paredFieldsSchema = {}; | ||
Object.keys(fieldsSchema).forEach(function (field) { | ||
var fieldSchema = fieldsSchema[field]; | ||
var fieldSchemaList = Array.isArray(fieldSchema) ? fieldSchema : [fieldSchema]; | ||
fieldsSchema = { ...fieldsSchema, | ||
...data.rule.fields | ||
}; | ||
const paredFieldsSchema = {}; | ||
Object.keys(fieldsSchema).forEach(field => { | ||
const fieldSchema = fieldsSchema[field]; | ||
const fieldSchemaList = Array.isArray(fieldSchema) ? fieldSchema : [fieldSchema]; | ||
paredFieldsSchema[field] = fieldSchemaList.map(addFullField.bind(null, field)); | ||
}); | ||
var schema = new Schema(paredFieldsSchema); | ||
const schema = new Schema(paredFieldsSchema); | ||
schema.messages(options.messages); | ||
@@ -1235,11 +1122,11 @@ | ||
schema.validate(data.value, data.rule.options || options, function (errs) { | ||
var finalErrors = []; | ||
schema.validate(data.value, data.rule.options || options, errs => { | ||
const finalErrors = []; | ||
if (filledErrors && filledErrors.length) { | ||
finalErrors.push.apply(finalErrors, filledErrors); | ||
finalErrors.push(...filledErrors); | ||
} | ||
if (errs && errs.length) { | ||
finalErrors.push.apply(finalErrors, errs); | ||
finalErrors.push(...errs); | ||
} | ||
@@ -1252,3 +1139,3 @@ | ||
var res; | ||
let res; | ||
@@ -1263,3 +1150,3 @@ if (rule.asyncValidator) { | ||
} else if (res === false) { | ||
cb(typeof rule.message === 'function' ? rule.message(rule.fullField || rule.field) : rule.message || (rule.fullField || rule.field) + " fails"); | ||
cb(typeof rule.message === 'function' ? rule.message(rule.fullField || rule.field) : rule.message || `${rule.fullField || rule.field} fails`); | ||
} else if (res instanceof Array) { | ||
@@ -1273,14 +1160,10 @@ cb(res); | ||
if (res && res.then) { | ||
res.then(function () { | ||
return cb(); | ||
}, function (e) { | ||
return cb(e); | ||
}); | ||
res.then(() => cb(), e => cb(e)); | ||
} | ||
}, function (results) { | ||
}, results => { | ||
complete(results); | ||
}, source); | ||
}; | ||
} | ||
_proto.getType = function getType(rule) { | ||
getType(rule) { | ||
if (rule.type === undefined && rule.pattern instanceof RegExp) { | ||
@@ -1295,5 +1178,5 @@ rule.type = 'pattern'; | ||
return rule.type || 'string'; | ||
}; | ||
} | ||
_proto.getValidationMethod = function getValidationMethod(rule) { | ||
getValidationMethod(rule) { | ||
if (typeof rule.validator === 'function') { | ||
@@ -1303,4 +1186,4 @@ return rule.validator; | ||
var keys = Object.keys(rule); | ||
var messageIndex = keys.indexOf('message'); | ||
const keys = Object.keys(rule); | ||
const messageIndex = keys.indexOf('message'); | ||
@@ -1316,20 +1199,7 @@ if (messageIndex !== -1) { | ||
return validators[this.getType(rule)] || undefined; | ||
}; | ||
return Schema; | ||
}(); | ||
Schema.register = function register(type, validator) { | ||
if (typeof validator !== 'function') { | ||
throw new Error('Cannot register a validator by type, validator is not a function'); | ||
} | ||
validators[type] = validator; | ||
}; | ||
} | ||
Schema.warning = warning; | ||
Schema.messages = messages; | ||
Schema.validators = validators; | ||
export { Schema as default }; | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "async-validator", | ||
"description": "validate form asynchronous", | ||
"version": "4.0.3", | ||
"version": "4.0.4", | ||
"license": "MIT", | ||
@@ -25,3 +25,5 @@ "files": [ | ||
}, | ||
"dependencies": {}, | ||
"dependencies": { | ||
"url-regex": "^5.0.0" | ||
}, | ||
"devDependencies": { | ||
@@ -28,0 +30,0 @@ "@babel/core": "^7.15.0", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 2 instances in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
243272
1
2135
4
+ Addedurl-regex@^5.0.0
+ Addedip-regex@4.3.0(transitive)
+ Addedtlds@1.255.0(transitive)
+ Addedurl-regex@5.0.0(transitive)