index.js.map 76 KB

1
  1. {"version":3,"file":"index.js","sources":["../../src/util.js","../../src/rule/required.js","../../src/rule/whitespace.js","../../src/rule/type.js","../../src/rule/range.js","../../src/rule/enum.js","../../src/rule/pattern.js","../../src/rule/index.js","../../src/validator/string.js","../../src/validator/method.js","../../src/validator/number.js","../../src/validator/boolean.js","../../src/validator/regexp.js","../../src/validator/integer.js","../../src/validator/float.js","../../src/validator/array.js","../../src/validator/object.js","../../src/validator/enum.js","../../src/validator/pattern.js","../../src/validator/date.js","../../src/validator/required.js","../../src/validator/type.js","../../src/validator/any.js","../../src/validator/index.js","../../src/messages.js","../../src/index.js"],"sourcesContent":["/* eslint no-console:0 */\n\nconst formatRegExp = /%[sdj%]/g;\n\nexport let warning = () => {\n};\n\n// don't print warning message when in production env or node runtime\nif (\n typeof process !== 'undefined' &&\n process.env &&\n process.env.NODE_ENV !== 'production' &&\n typeof window !== 'undefined' &&\n typeof document !== 'undefined'\n) {\n warning = (type, errors) => {\n if (typeof console !== 'undefined' && console.warn) {\n if (errors.every(e => typeof e === 'string')) {\n console.warn(type, errors);\n }\n }\n };\n}\n\nexport function convertFieldsError(errors) {\n if (!errors || !errors.length) return null;\n const fields = {};\n errors.forEach(error => {\n const field = error.field;\n fields[field] = fields[field] || [];\n fields[field].push(error);\n });\n return fields;\n}\n\nexport function format(...args) {\n let i = 1;\n const f = args[0];\n const len = args.length;\n if (typeof f === 'function') {\n return f.apply(null, args.slice(1));\n }\n if (typeof f === 'string') {\n let str = String(f).replace(formatRegExp, x => {\n if (x === '%%') {\n return '%';\n }\n if (i >= len) {\n return x;\n }\n switch (x) {\n case '%s':\n return String(args[i++]);\n case '%d':\n return Number(args[i++]);\n case '%j':\n try {\n return JSON.stringify(args[i++]);\n } catch (_) {\n return '[Circular]';\n }\n break;\n default:\n return x;\n }\n });\n for (let arg = args[i]; i < len; arg = args[++i]) {\n str += ` ${arg}`;\n }\n return str;\n }\n return f;\n}\n\nfunction isNativeStringType(type) {\n return (\n type === 'string' ||\n type === 'url' ||\n type === 'hex' ||\n type === 'email' ||\n type === 'pattern'\n );\n}\n\nexport function isEmptyValue(value, type) {\n if (value === undefined || value === null) {\n return true;\n }\n if (type === 'array' && Array.isArray(value) && !value.length) {\n return true;\n }\n if (isNativeStringType(type) && typeof value === 'string' && !value) {\n return true;\n }\n return false;\n}\n\nexport function isEmptyObject(obj) {\n return Object.keys(obj).length === 0;\n}\n\nfunction asyncParallelArray(arr, func, callback) {\n const results = [];\n let total = 0;\n const arrLength = arr.length;\n\n function count(errors) {\n results.push.apply(results, errors);\n total++;\n if (total === arrLength) {\n callback(results);\n }\n }\n\n arr.forEach(a => {\n func(a, count);\n });\n}\n\nfunction asyncSerialArray(arr, func, callback) {\n let index = 0;\n const arrLength = arr.length;\n\n function next(errors) {\n if (errors && errors.length) {\n callback(errors);\n return;\n }\n const original = index;\n index = index + 1;\n if (original < arrLength) {\n func(arr[original], next);\n } else {\n callback([]);\n }\n }\n\n next([]);\n}\n\nfunction flattenObjArr(objArr) {\n const ret = [];\n Object.keys(objArr).forEach(k => {\n ret.push.apply(ret, objArr[k]);\n });\n return ret;\n}\n\nexport function asyncMap(objArr, option, func, callback) {\n if (option.first) {\n const pending = new Promise((resolve, reject) => {\n const next = errors => {\n callback(errors);\n return errors.length\n ? reject({ errors, fields: convertFieldsError(errors) })\n : resolve();\n };\n const flattenArr = flattenObjArr(objArr);\n asyncSerialArray(flattenArr, func, next);\n });\n pending.catch(e => e);\n return pending;\n }\n let firstFields = option.firstFields || [];\n if (firstFields === true) {\n firstFields = Object.keys(objArr);\n }\n const objArrKeys = Object.keys(objArr);\n const objArrLength = objArrKeys.length;\n let total = 0;\n const results = [];\n const pending = new Promise((resolve, reject) => {\n const next = errors => {\n results.push.apply(results, errors);\n total++;\n if (total === objArrLength) {\n callback(results);\n return results.length\n ? reject({ errors: results, fields: convertFieldsError(results) })\n : resolve();\n }\n };\n if (!objArrKeys.length) {\n callback(results)\n resolve()\n }\n objArrKeys.forEach(key => {\n const arr = objArr[key];\n if (firstFields.indexOf(key) !== -1) {\n asyncSerialArray(arr, func, next);\n } else {\n asyncParallelArray(arr, func, next);\n }\n });\n });\n pending.catch(e => e);\n return pending;\n}\n\nexport function complementError(rule) {\n return oe => {\n if (oe && oe.message) {\n oe.field = oe.field || rule.fullField;\n return oe;\n }\n return {\n message: typeof oe === 'function' ? oe() : oe,\n field: oe.field || rule.fullField,\n };\n };\n}\n\nexport function deepMerge(target, source) {\n if (source) {\n for (const s in source) {\n if (source.hasOwnProperty(s)) {\n const value = source[s];\n if (typeof value === 'object' && typeof target[s] === 'object') {\n target[s] = {\n ...target[s],\n ...value,\n };\n } else {\n target[s] = value;\n }\n }\n }\n }\n return target;\n}\n","import * as util from '../util';\n\n/**\n * Rule for validating required fields.\n *\n * @param rule The validation rule.\n * @param value The value of the field on the source object.\n * @param source The source object being validated.\n * @param errors An array of errors that this rule may add\n * validation errors to.\n * @param options The validation options.\n * @param options.messages The validation messages.\n */\nfunction required(rule, value, source, errors, options, type) {\n if (\n rule.required &&\n (!source.hasOwnProperty(rule.field) ||\n util.isEmptyValue(value, type || rule.type))\n ) {\n errors.push(util.format(options.messages.required, rule.fullField));\n }\n}\n\nexport default required;\n","import * as util from '../util';\n\n/**\n * Rule for validating whitespace.\n *\n * @param rule The validation rule.\n * @param value The value of the field on the source object.\n * @param source The source object being validated.\n * @param errors An array of errors that this rule may add\n * validation errors to.\n * @param options The validation options.\n * @param options.messages The validation messages.\n */\nfunction whitespace(rule, value, source, errors, options) {\n if (/^\\s+$/.test(value) || value === '') {\n errors.push(util.format(options.messages.whitespace, rule.fullField));\n }\n}\n\nexport default whitespace;\n","import * as util from '../util';\nimport required from './required';\n\n/* eslint max-len:0 */\n\nconst pattern = {\n // http://emailregex.com/\n 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,}))$/,\n url: new RegExp(\n '^(?!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]*)?$',\n 'i',\n ),\n hex: /^#?([a-f0-9]{6}|[a-f0-9]{3})$/i,\n};\n\nconst types = {\n integer(value) {\n return types.number(value) && parseInt(value, 10) === value;\n },\n float(value) {\n return types.number(value) && !types.integer(value);\n },\n array(value) {\n return Array.isArray(value);\n },\n regexp(value) {\n if (value instanceof RegExp) {\n return true;\n }\n try {\n return !!new RegExp(value);\n } catch (e) {\n return false;\n }\n },\n date(value) {\n return (\n typeof value.getTime === 'function' &&\n typeof value.getMonth === 'function' &&\n typeof value.getYear === 'function'\n );\n },\n number(value) {\n if (isNaN(value)) {\n return false;\n }\n return typeof value === 'number';\n },\n object(value) {\n return typeof value === 'object' && !types.array(value);\n },\n method(value) {\n return typeof value === 'function';\n },\n email(value) {\n return (\n typeof value === 'string' &&\n !!value.match(pattern.email) &&\n value.length < 255\n );\n },\n url(value) {\n return typeof value === 'string' && !!value.match(pattern.url);\n },\n hex(value) {\n return typeof value === 'string' && !!value.match(pattern.hex);\n },\n};\n\n/**\n * Rule for validating the type of a value.\n *\n * @param rule The validation rule.\n * @param value The value of the field on the source object.\n * @param source The source object being validated.\n * @param errors An array of errors that this rule may add\n * validation errors to.\n * @param options The validation options.\n * @param options.messages The validation messages.\n */\nfunction type(rule, value, source, errors, options) {\n if (rule.required && value === undefined) {\n required(rule, value, source, errors, options);\n return;\n }\n const custom = [\n 'integer',\n 'float',\n 'array',\n 'regexp',\n 'object',\n 'method',\n 'email',\n 'number',\n 'date',\n 'url',\n 'hex',\n ];\n const ruleType = rule.type;\n if (custom.indexOf(ruleType) > -1) {\n if (!types[ruleType](value)) {\n errors.push(\n util.format(\n options.messages.types[ruleType],\n rule.fullField,\n rule.type,\n ),\n );\n }\n // straight typeof check\n } else if (ruleType && typeof value !== rule.type) {\n errors.push(\n util.format(options.messages.types[ruleType], rule.fullField, rule.type),\n );\n }\n}\n\nexport default type;\n","import * as util from '../util';\n\n/**\n * Rule for validating minimum and maximum allowed values.\n *\n * @param rule The validation rule.\n * @param value The value of the field on the source object.\n * @param source The source object being validated.\n * @param errors An array of errors that this rule may add\n * validation errors to.\n * @param options The validation options.\n * @param options.messages The validation messages.\n */\nfunction range(rule, value, source, errors, options) {\n const len = typeof rule.len === 'number';\n const min = typeof rule.min === 'number';\n const max = typeof rule.max === 'number';\n // 正则匹配码点范围从U+010000一直到U+10FFFF的文字(补充平面Supplementary Plane)\n const spRegexp = /[\\uD800-\\uDBFF][\\uDC00-\\uDFFF]/g;\n let val = value;\n let key = null;\n const num = typeof value === 'number';\n const str = typeof value === 'string';\n const arr = Array.isArray(value);\n if (num) {\n key = 'number';\n } else if (str) {\n key = 'string';\n } else if (arr) {\n key = 'array';\n }\n // if the value is not of a supported type for range validation\n // the validation rule rule should use the\n // type property to also test for a particular type\n if (!key) {\n return false;\n }\n if (arr) {\n val = value.length;\n }\n if (str) {\n // 处理码点大于U+010000的文字length属性不准确的bug,如\"𠮷𠮷𠮷\".lenght !== 3\n val = value.replace(spRegexp, '_').length;\n }\n if (len) {\n if (val !== rule.len) {\n errors.push(\n util.format(options.messages[key].len, rule.fullField, rule.len),\n );\n }\n } else if (min && !max && val < rule.min) {\n errors.push(\n util.format(options.messages[key].min, rule.fullField, rule.min),\n );\n } else if (max && !min && val > rule.max) {\n errors.push(\n util.format(options.messages[key].max, rule.fullField, rule.max),\n );\n } else if (min && max && (val < rule.min || val > rule.max)) {\n errors.push(\n util.format(\n options.messages[key].range,\n rule.fullField,\n rule.min,\n rule.max,\n ),\n );\n }\n}\n\nexport default range;\n","import * as util from '../util';\n\nconst ENUM = 'enum';\n\n/**\n * Rule for validating a value exists in an enumerable list.\n *\n * @param rule The validation rule.\n * @param value The value of the field on the source object.\n * @param source The source object being validated.\n * @param errors An array of errors that this rule may add\n * validation errors to.\n * @param options The validation options.\n * @param options.messages The validation messages.\n */\nfunction enumerable(rule, value, source, errors, options) {\n rule[ENUM] = Array.isArray(rule[ENUM]) ? rule[ENUM] : [];\n if (rule[ENUM].indexOf(value) === -1) {\n errors.push(\n util.format(\n options.messages[ENUM],\n rule.fullField,\n rule[ENUM].join(', '),\n ),\n );\n }\n}\n\nexport default enumerable;\n","import * as util from '../util';\n\n/**\n * Rule for validating a regular expression pattern.\n *\n * @param rule The validation rule.\n * @param value The value of the field on the source object.\n * @param source The source object being validated.\n * @param errors An array of errors that this rule may add\n * validation errors to.\n * @param options The validation options.\n * @param options.messages The validation messages.\n */\nfunction pattern(rule, value, source, errors, options) {\n if (rule.pattern) {\n if (rule.pattern instanceof RegExp) {\n // if a RegExp instance is passed, reset `lastIndex` in case its `global`\n // flag is accidentally set to `true`, which in a validation scenario\n // is not necessary and the result might be misleading\n rule.pattern.lastIndex = 0;\n if (!rule.pattern.test(value)) {\n errors.push(\n util.format(\n options.messages.pattern.mismatch,\n rule.fullField,\n value,\n rule.pattern,\n ),\n );\n }\n } else if (typeof rule.pattern === 'string') {\n const _pattern = new RegExp(rule.pattern);\n if (!_pattern.test(value)) {\n errors.push(\n util.format(\n options.messages.pattern.mismatch,\n rule.fullField,\n value,\n rule.pattern,\n ),\n );\n }\n }\n }\n}\n\nexport default pattern;\n","import required from './required';\nimport whitespace from './whitespace';\nimport type from './type';\nimport range from './range';\nimport enumRule from './enum';\nimport pattern from './pattern';\n\nexport default {\n required,\n whitespace,\n type,\n range,\n enum: enumRule,\n pattern,\n};\n","import rules from '../rule/index.js';\nimport { isEmptyValue } from '../util';\n\n/**\n * Performs validation for string types.\n *\n * @param rule The validation rule.\n * @param value The value of the field on the source object.\n * @param callback The callback function.\n * @param source The source object being validated.\n * @param options The validation options.\n * @param options.messages The validation messages.\n */\nfunction string(rule, value, callback, source, options) {\n const errors = [];\n const validate =\n rule.required || (!rule.required && source.hasOwnProperty(rule.field));\n if (validate) {\n if (isEmptyValue(value, 'string') && !rule.required) {\n return callback();\n }\n rules.required(rule, value, source, errors, options, 'string');\n if (!isEmptyValue(value, 'string')) {\n rules.type(rule, value, source, errors, options);\n rules.range(rule, value, source, errors, options);\n rules.pattern(rule, value, source, errors, options);\n if (rule.whitespace === true) {\n rules.whitespace(rule, value, source, errors, options);\n }\n }\n }\n callback(errors);\n}\n\nexport default string;\n","import rules from '../rule/index.js';\nimport { isEmptyValue } from '../util';\n\n/**\n * Validates a function.\n *\n * @param rule The validation rule.\n * @param value The value of the field on the source object.\n * @param callback The callback function.\n * @param source The source object being validated.\n * @param options The validation options.\n * @param options.messages The validation messages.\n */\nfunction method(rule, value, callback, source, options) {\n const errors = [];\n const validate =\n rule.required || (!rule.required && source.hasOwnProperty(rule.field));\n if (validate) {\n if (isEmptyValue(value) && !rule.required) {\n return callback();\n }\n rules.required(rule, value, source, errors, options);\n if (value !== undefined) {\n rules.type(rule, value, source, errors, options);\n }\n }\n callback(errors);\n}\n\nexport default method;\n","import rules from '../rule/index.js';\nimport { isEmptyValue } from '../util';\n\n/**\n * Validates a number.\n *\n * @param rule The validation rule.\n * @param value The value of the field on the source object.\n * @param callback The callback function.\n * @param source The source object being validated.\n * @param options The validation options.\n * @param options.messages The validation messages.\n */\nfunction number(rule, value, callback, source, options) {\n const errors = [];\n const validate =\n rule.required || (!rule.required && source.hasOwnProperty(rule.field));\n if (validate) {\n if (value === '') {\n value = undefined;\n }\n if (isEmptyValue(value) && !rule.required) {\n return callback();\n }\n rules.required(rule, value, source, errors, options);\n if (value !== undefined) {\n rules.type(rule, value, source, errors, options);\n rules.range(rule, value, source, errors, options);\n }\n }\n callback(errors);\n}\n\nexport default number;\n","import { isEmptyValue } from '../util';\nimport rules from '../rule/index.js';\n\n/**\n * Validates a boolean.\n *\n * @param rule The validation rule.\n * @param value The value of the field on the source object.\n * @param callback The callback function.\n * @param source The source object being validated.\n * @param options The validation options.\n * @param options.messages The validation messages.\n */\nfunction boolean(rule, value, callback, source, options) {\n const errors = [];\n const validate =\n rule.required || (!rule.required && source.hasOwnProperty(rule.field));\n if (validate) {\n if (isEmptyValue(value) && !rule.required) {\n return callback();\n }\n rules.required(rule, value, source, errors, options);\n if (value !== undefined) {\n rules.type(rule, value, source, errors, options);\n }\n }\n callback(errors);\n}\n\nexport default boolean;\n","import rules from '../rule/index.js';\nimport { isEmptyValue } from '../util';\n\n/**\n * Validates the regular expression type.\n *\n * @param rule The validation rule.\n * @param value The value of the field on the source object.\n * @param callback The callback function.\n * @param source The source object being validated.\n * @param options The validation options.\n * @param options.messages The validation messages.\n */\nfunction regexp(rule, value, callback, source, options) {\n const errors = [];\n const validate =\n rule.required || (!rule.required && source.hasOwnProperty(rule.field));\n if (validate) {\n if (isEmptyValue(value) && !rule.required) {\n return callback();\n }\n rules.required(rule, value, source, errors, options);\n if (!isEmptyValue(value)) {\n rules.type(rule, value, source, errors, options);\n }\n }\n callback(errors);\n}\n\nexport default regexp;\n","import rules from '../rule/index.js';\nimport { isEmptyValue } from '../util';\n\n/**\n * Validates a number is an integer.\n *\n * @param rule The validation rule.\n * @param value The value of the field on the source object.\n * @param callback The callback function.\n * @param source The source object being validated.\n * @param options The validation options.\n * @param options.messages The validation messages.\n */\nfunction integer(rule, value, callback, source, options) {\n const errors = [];\n const validate =\n rule.required || (!rule.required && source.hasOwnProperty(rule.field));\n if (validate) {\n if (isEmptyValue(value) && !rule.required) {\n return callback();\n }\n rules.required(rule, value, source, errors, options);\n if (value !== undefined) {\n rules.type(rule, value, source, errors, options);\n rules.range(rule, value, source, errors, options);\n }\n }\n callback(errors);\n}\n\nexport default integer;\n","import rules from '../rule/index.js';\nimport { isEmptyValue } from '../util';\n\n/**\n * Validates a number is a floating point number.\n *\n * @param rule The validation rule.\n * @param value The value of the field on the source object.\n * @param callback The callback function.\n * @param source The source object being validated.\n * @param options The validation options.\n * @param options.messages The validation messages.\n */\nfunction floatFn(rule, value, callback, source, options) {\n const errors = [];\n const validate =\n rule.required || (!rule.required && source.hasOwnProperty(rule.field));\n if (validate) {\n if (isEmptyValue(value) && !rule.required) {\n return callback();\n }\n rules.required(rule, value, source, errors, options);\n if (value !== undefined) {\n rules.type(rule, value, source, errors, options);\n rules.range(rule, value, source, errors, options);\n }\n }\n callback(errors);\n}\n\nexport default floatFn;\n","import rules from '../rule/index';\nimport { isEmptyValue } from '../util';\n/**\n * Validates an array.\n *\n * @param rule The validation rule.\n * @param value The value of the field on the source object.\n * @param callback The callback function.\n * @param source The source object being validated.\n * @param options The validation options.\n * @param options.messages The validation messages.\n */\nfunction array(rule, value, callback, source, options) {\n const errors = [];\n const validate =\n rule.required || (!rule.required && source.hasOwnProperty(rule.field));\n if (validate) {\n if (isEmptyValue(value, 'array') && !rule.required) {\n return callback();\n }\n rules.required(rule, value, source, errors, options, 'array');\n if (!isEmptyValue(value, 'array')) {\n rules.type(rule, value, source, errors, options);\n rules.range(rule, value, source, errors, options);\n }\n }\n callback(errors);\n}\n\nexport default array;\n","import rules from '../rule/index.js';\nimport { isEmptyValue } from '../util';\n\n/**\n * Validates an object.\n *\n * @param rule The validation rule.\n * @param value The value of the field on the source object.\n * @param callback The callback function.\n * @param source The source object being validated.\n * @param options The validation options.\n * @param options.messages The validation messages.\n */\nfunction object(rule, value, callback, source, options) {\n const errors = [];\n const validate =\n rule.required || (!rule.required && source.hasOwnProperty(rule.field));\n if (validate) {\n if (isEmptyValue(value) && !rule.required) {\n return callback();\n }\n rules.required(rule, value, source, errors, options);\n if (value !== undefined) {\n rules.type(rule, value, source, errors, options);\n }\n }\n callback(errors);\n}\n\nexport default object;\n","import rules from '../rule/index.js';\nimport { isEmptyValue } from '../util';\n\nconst ENUM = 'enum';\n\n/**\n * Validates an enumerable list.\n *\n * @param rule The validation rule.\n * @param value The value of the field on the source object.\n * @param callback The callback function.\n * @param source The source object being validated.\n * @param options The validation options.\n * @param options.messages The validation messages.\n */\nfunction enumerable(rule, value, callback, source, options) {\n const errors = [];\n const validate =\n rule.required || (!rule.required && source.hasOwnProperty(rule.field));\n if (validate) {\n if (isEmptyValue(value) && !rule.required) {\n return callback();\n }\n rules.required(rule, value, source, errors, options);\n if (value !== undefined) {\n rules[ENUM](rule, value, source, errors, options);\n }\n }\n callback(errors);\n}\n\nexport default enumerable;\n","import rules from '../rule/index.js';\nimport { isEmptyValue } from '../util';\n\n/**\n * Validates a regular expression pattern.\n *\n * Performs validation when a rule only contains\n * a pattern property but is not declared as a string type.\n *\n * @param rule The validation rule.\n * @param value The value of the field on the source object.\n * @param callback The callback function.\n * @param source The source object being validated.\n * @param options The validation options.\n * @param options.messages The validation messages.\n */\nfunction pattern(rule, value, callback, source, options) {\n const errors = [];\n const validate =\n rule.required || (!rule.required && source.hasOwnProperty(rule.field));\n if (validate) {\n if (isEmptyValue(value, 'string') && !rule.required) {\n return callback();\n }\n rules.required(rule, value, source, errors, options);\n if (!isEmptyValue(value, 'string')) {\n rules.pattern(rule, value, source, errors, options);\n }\n }\n callback(errors);\n}\n\nexport default pattern;\n","import rules from '../rule/index.js';\nimport { isEmptyValue } from '../util';\n\nfunction date(rule, value, callback, source, options) {\n // console.log('integer rule called %j', rule);\n const errors = [];\n const validate =\n rule.required || (!rule.required && source.hasOwnProperty(rule.field));\n // console.log('validate on %s value', value);\n if (validate) {\n if (isEmptyValue(value) && !rule.required) {\n return callback();\n }\n rules.required(rule, value, source, errors, options);\n if (!isEmptyValue(value)) {\n let dateObject;\n\n if (typeof value === 'number') {\n dateObject = new Date(value);\n } else {\n dateObject = value;\n }\n\n rules.type(rule, dateObject, source, errors, options);\n if (dateObject) {\n rules.range(rule, dateObject.getTime(), source, errors, options);\n }\n }\n }\n callback(errors);\n}\n\nexport default date;\n","import rules from '../rule/index.js';\n\nfunction required(rule, value, callback, source, options) {\n const errors = [];\n const type = Array.isArray(value) ? 'array' : typeof value;\n rules.required(rule, value, source, errors, options, type);\n callback(errors);\n}\n\nexport default required;\n","import rules from '../rule/index.js';\nimport { isEmptyValue } from '../util';\n\nfunction type(rule, value, callback, source, options) {\n const ruleType = rule.type;\n const errors = [];\n const validate =\n rule.required || (!rule.required && source.hasOwnProperty(rule.field));\n if (validate) {\n if (isEmptyValue(value, ruleType) && !rule.required) {\n return callback();\n }\n rules.required(rule, value, source, errors, options, ruleType);\n if (!isEmptyValue(value, ruleType)) {\n rules.type(rule, value, source, errors, options);\n }\n }\n callback(errors);\n}\n\nexport default type;\n","import rules from '../rule/index.js';\nimport { isEmptyValue } from '../util';\n\n/**\n * Performs validation for any type.\n *\n * @param rule The validation rule.\n * @param value The value of the field on the source object.\n * @param callback The callback function.\n * @param source The source object being validated.\n * @param options The validation options.\n * @param options.messages The validation messages.\n */\nfunction any(rule, value, callback, source, options) {\n const errors = [];\n const validate =\n rule.required || (!rule.required && source.hasOwnProperty(rule.field));\n if (validate) {\n if (isEmptyValue(value) && !rule.required) {\n return callback();\n }\n rules.required(rule, value, source, errors, options);\n }\n callback(errors);\n}\n\nexport default any;\n","import string from './string';\nimport method from './method';\nimport number from './number';\nimport boolean from './boolean';\nimport regexp from './regexp';\nimport integer from './integer';\nimport float from './float';\nimport array from './array';\nimport object from './object';\nimport enumValidator from './enum';\nimport pattern from './pattern';\nimport date from './date';\nimport required from './required';\nimport type from './type';\nimport any from './any';\n\nexport default {\n string,\n method,\n number,\n boolean,\n regexp,\n integer,\n float,\n array,\n object,\n enum: enumValidator,\n pattern,\n date,\n url: type,\n hex: type,\n email: type,\n required,\n any,\n};\n","export function newMessages() {\n return {\n default: 'Validation error on field %s',\n required: '%s is required',\n enum: '%s must be one of %s',\n whitespace: '%s cannot be empty',\n date: {\n format: '%s date %s is invalid for format %s',\n parse: '%s date could not be parsed, %s is invalid ',\n invalid: '%s date %s is invalid',\n },\n types: {\n string: '%s is not a %s',\n method: '%s is not a %s (function)',\n array: '%s is not an %s',\n object: '%s is not an %s',\n number: '%s is not a %s',\n date: '%s is not a %s',\n boolean: '%s is not a %s',\n integer: '%s is not an %s',\n float: '%s is not a %s',\n regexp: '%s is not a valid %s',\n email: '%s is not a valid %s',\n url: '%s is not a valid %s',\n hex: '%s is not a valid %s',\n },\n string: {\n len: '%s must be exactly %s characters',\n min: '%s must be at least %s characters',\n max: '%s cannot be longer than %s characters',\n range: '%s must be between %s and %s characters',\n },\n number: {\n len: '%s must equal %s',\n min: '%s cannot be less than %s',\n max: '%s cannot be greater than %s',\n range: '%s must be between %s and %s',\n },\n array: {\n len: '%s must be exactly %s in length',\n min: '%s cannot be less than %s in length',\n max: '%s cannot be greater than %s in length',\n range: '%s must be between %s and %s in length',\n },\n pattern: {\n mismatch: '%s value %s does not match pattern %s',\n },\n clone() {\n const cloned = JSON.parse(JSON.stringify(this));\n cloned.clone = this.clone;\n return cloned;\n },\n };\n}\n\nexport const messages = newMessages();\n","import {\n format,\n complementError,\n asyncMap,\n warning,\n deepMerge,\n convertFieldsError,\n} from './util';\nimport validators from './validator/index';\nimport { messages as defaultMessages, newMessages } from './messages';\n\n/**\n * Encapsulates a validation schema.\n *\n * @param descriptor An object declaring validation rules\n * for this schema.\n */\nfunction Schema(descriptor) {\n this.rules = null;\n this._messages = defaultMessages;\n this.define(descriptor);\n}\n\nSchema.prototype = {\n messages(messages) {\n if (messages) {\n this._messages = deepMerge(newMessages(), messages);\n }\n return this._messages;\n },\n define(rules) {\n if (!rules) {\n throw new Error('Cannot configure a schema with no rules');\n }\n if (typeof rules !== 'object' || Array.isArray(rules)) {\n throw new Error('Rules must be an object');\n }\n this.rules = {};\n let z;\n let item;\n for (z in rules) {\n if (rules.hasOwnProperty(z)) {\n item = rules[z];\n this.rules[z] = Array.isArray(item) ? item : [item];\n }\n }\n },\n validate(source_, o = {}, oc = () => {}) {\n let source = source_;\n let options = o;\n let callback = oc;\n if (typeof options === 'function') {\n callback = options;\n options = {};\n }\n if (!this.rules || Object.keys(this.rules).length === 0) {\n if (callback) {\n callback();\n }\n return Promise.resolve();\n }\n\n function complete(results) {\n let i;\n let errors = [];\n let fields = {};\n\n function add(e) {\n if (Array.isArray(e)) {\n errors = errors.concat(...e);\n } else {\n errors.push(e);\n }\n }\n\n for (i = 0; i < results.length; i++) {\n add(results[i]);\n }\n if (!errors.length) {\n errors = null;\n fields = null;\n } else {\n fields = convertFieldsError(errors);\n }\n callback(errors, fields);\n }\n\n if (options.messages) {\n let messages = this.messages();\n if (messages === defaultMessages) {\n messages = newMessages();\n }\n deepMerge(messages, options.messages);\n options.messages = messages;\n } else {\n options.messages = this.messages();\n }\n let arr;\n let value;\n const series = {};\n const keys = options.keys || Object.keys(this.rules);\n keys.forEach(z => {\n arr = this.rules[z];\n value = source[z];\n arr.forEach(r => {\n let rule = r;\n if (typeof rule.transform === 'function') {\n if (source === source_) {\n source = { ...source };\n }\n value = source[z] = rule.transform(value);\n }\n if (typeof rule === 'function') {\n rule = {\n validator: rule,\n };\n } else {\n rule = { ...rule };\n }\n rule.validator = this.getValidationMethod(rule);\n rule.field = z;\n rule.fullField = rule.fullField || z;\n rule.type = this.getType(rule);\n if (!rule.validator) {\n return;\n }\n series[z] = series[z] || [];\n series[z].push({\n rule,\n value,\n source,\n field: z,\n });\n });\n });\n const errorFields = {};\n return asyncMap(\n series,\n options,\n (data, doIt) => {\n const rule = data.rule;\n let deep =\n (rule.type === 'object' || rule.type === 'array') &&\n (typeof rule.fields === 'object' ||\n typeof rule.defaultField === 'object');\n deep = deep && (rule.required || (!rule.required && data.value));\n rule.field = data.field;\n\n function addFullfield(key, schema) {\n return {\n ...schema,\n fullField: `${rule.fullField}.${key}`,\n };\n }\n\n function cb(e = []) {\n let errors = e;\n if (!Array.isArray(errors)) {\n errors = [errors];\n }\n if (!options.suppressWarning && errors.length) {\n Schema.warning('async-validator:', errors);\n }\n if (errors.length && rule.message) {\n errors = [].concat(rule.message);\n }\n\n errors = errors.map(complementError(rule));\n\n if (options.first && errors.length) {\n errorFields[rule.field] = 1;\n return doIt(errors);\n }\n if (!deep) {\n doIt(errors);\n } else {\n // if rule is required but the target object\n // does not exist fail at the rule level and don't\n // go deeper\n if (rule.required && !data.value) {\n if (rule.message) {\n errors = [].concat(rule.message).map(complementError(rule));\n } else if (options.error) {\n errors = [\n options.error(\n rule,\n format(options.messages.required, rule.field),\n ),\n ];\n } else {\n errors = [];\n }\n return doIt(errors);\n }\n\n let fieldsSchema = {};\n if (rule.defaultField) {\n for (const k in data.value) {\n if (data.value.hasOwnProperty(k)) {\n fieldsSchema[k] = rule.defaultField;\n }\n }\n }\n fieldsSchema = {\n ...fieldsSchema,\n ...data.rule.fields,\n };\n for (const f in fieldsSchema) {\n if (fieldsSchema.hasOwnProperty(f)) {\n const fieldSchema = Array.isArray(fieldsSchema[f])\n ? fieldsSchema[f]\n : [fieldsSchema[f]];\n fieldsSchema[f] = fieldSchema.map(addFullfield.bind(null, f));\n }\n }\n const schema = new Schema(fieldsSchema);\n schema.messages(options.messages);\n if (data.rule.options) {\n data.rule.options.messages = options.messages;\n data.rule.options.error = options.error;\n }\n schema.validate(data.value, data.rule.options || options, errs => {\n const finalErrors = [];\n if (errors && errors.length) {\n finalErrors.push(...errors);\n }\n if (errs && errs.length) {\n finalErrors.push(...errs);\n }\n doIt(finalErrors.length ? finalErrors : null);\n });\n }\n }\n\n let res;\n if (rule.asyncValidator) {\n res = rule.asyncValidator(rule, data.value, cb, data.source, options);\n } else if (rule.validator) {\n res = rule.validator(rule, data.value, cb, data.source, options);\n if (res === true) {\n cb();\n } else if (res === false) {\n cb(rule.message || `${rule.field} fails`);\n } else if (res instanceof Array) {\n cb(res);\n } else if (res instanceof Error) {\n cb(res.message);\n }\n }\n if (res && res.then) {\n res.then(() => cb(), e => cb(e));\n }\n },\n results => {\n complete(results);\n },\n );\n },\n getType(rule) {\n if (rule.type === undefined && rule.pattern instanceof RegExp) {\n rule.type = 'pattern';\n }\n if (\n typeof rule.validator !== 'function' &&\n (rule.type && !validators.hasOwnProperty(rule.type))\n ) {\n throw new Error(format('Unknown rule type %s', rule.type));\n }\n return rule.type || 'string';\n },\n getValidationMethod(rule) {\n if (typeof rule.validator === 'function') {\n return rule.validator;\n }\n const keys = Object.keys(rule);\n const messageIndex = keys.indexOf('message');\n if (messageIndex !== -1) {\n keys.splice(messageIndex, 1);\n }\n if (keys.length === 1 && keys[0] === 'required') {\n return validators.required;\n }\n return validators[this.getType(rule)] || false;\n },\n};\n\nSchema.register = function register(type, validator) {\n if (typeof validator !== 'function') {\n throw new Error(\n 'Cannot register a validator by type, validator is not a function',\n );\n }\n validators[type] = validator;\n};\n\nSchema.warning = warning;\n\nSchema.messages = defaultMessages;\n\nexport default Schema;\n"],"names":["formatRegExp","warning","process","env","NODE_ENV","window","document","type","errors","console","warn","every","e","convertFieldsError","length","fields","forEach","error","field","push","format","args","i","f","len","apply","slice","str","String","replace","x","Number","JSON","stringify","_","arg","isNativeStringType","isEmptyValue","value","undefined","Array","isArray","asyncParallelArray","arr","func","callback","results","total","arrLength","count","a","asyncSerialArray","index","next","original","flattenObjArr","objArr","ret","Object","keys","k","asyncMap","option","first","pending","Promise","resolve","reject","flattenArr","firstFields","objArrKeys","objArrLength","key","indexOf","complementError","rule","oe","message","fullField","deepMerge","target","source","s","hasOwnProperty","required","options","util","messages","whitespace","test","pattern","email","url","RegExp","hex","types","integer","number","parseInt","array","regexp","date","getTime","getMonth","getYear","isNaN","object","method","match","custom","ruleType","range","min","max","spRegexp","val","num","ENUM","enumerable","join","lastIndex","mismatch","_pattern","enumRule","string","validate","rules","boolean","floatFn","dateObject","Date","any","float","enumValidator","newMessages","parse","invalid","clone","cloned","Schema","descriptor","_messages","defaultMessages","define","prototype","Error","z","item","source_","o","oc","complete","add","concat","series","r","transform","validator","getValidationMethod","getType","errorFields","data","doIt","deep","defaultField","addFullfield","schema","cb","suppressWarning","map","fieldsSchema","fieldSchema","bind","errs","finalErrors","res","asyncValidator","then","validators","messageIndex","splice","register"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAEA,IAAMA,YAAY,GAAG,UAArB;AAEO,IAAIC,OAAO,GAAG,mBAAM,EAApB;;AAIP,IACE,OAAOC,OAAP,KAAmB,WAAnB,IACAA,OAAO,CAACC,GADR,IAEAD,OAAO,CAACC,GAAR,CAAYC,QAAZ,KAAyB,YAFzB,IAGA,OAAOC,MAAP,KAAkB,WAHlB,IAIA,OAAOC,QAAP,KAAoB,WALtB,EAME;AACAL,EAAAA,OAAO,GAAG,iBAACM,IAAD,EAAOC,MAAP,EAAkB;AAC1B,QAAI,OAAOC,OAAP,KAAmB,WAAnB,IAAkCA,OAAO,CAACC,IAA9C,EAAoD;AAClD,UAAIF,MAAM,CAACG,KAAP,CAAa,UAAAC,CAAC;AAAA,eAAI,OAAOA,CAAP,KAAa,QAAjB;AAAA,OAAd,CAAJ,EAA8C;AAC5CH,QAAAA,OAAO,CAACC,IAAR,CAAaH,IAAb,EAAmBC,MAAnB;AACD;AACF;AACF,GAND;AAOD;;AAEM,SAASK,kBAAT,CAA4BL,MAA5B,EAAoC;AACzC,MAAI,CAACA,MAAD,IAAW,CAACA,MAAM,CAACM,MAAvB,EAA+B,OAAO,IAAP;AAC/B,MAAMC,MAAM,GAAG,EAAf;AACAP,EAAAA,MAAM,CAACQ,OAAP,CAAe,UAAAC,KAAK,EAAI;AACtB,QAAMC,KAAK,GAAGD,KAAK,CAACC,KAApB;AACAH,IAAAA,MAAM,CAACG,KAAD,CAAN,GAAgBH,MAAM,CAACG,KAAD,CAAN,IAAiB,EAAjC;AACAH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