uview-pro 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (238) hide show
  1. package/changelog.md +424 -406
  2. package/components/u-action-sheet/types.ts +35 -35
  3. package/components/u-action-sheet/u-action-sheet.vue +160 -160
  4. package/components/u-alert-tips/types.ts +39 -39
  5. package/components/u-alert-tips/u-alert-tips.vue +212 -212
  6. package/components/u-avatar/types.ts +34 -34
  7. package/components/u-avatar/u-avatar.vue +193 -193
  8. package/components/u-avatar-cropper/types.ts +23 -23
  9. package/components/u-avatar-cropper/u-avatar-cropper.vue +286 -286
  10. package/components/u-avatar-cropper/weCropper.d.ts +62 -62
  11. package/components/u-avatar-cropper/weCropper.js +1253 -1253
  12. package/components/u-avatar-cropper/weCropper.ts +1255 -1255
  13. package/components/u-back-top/types.ts +39 -39
  14. package/components/u-back-top/u-back-top.vue +125 -125
  15. package/components/u-badge/types.ts +36 -36
  16. package/components/u-badge/u-badge.vue +165 -165
  17. package/components/u-button/types.ts +66 -66
  18. package/components/u-button/u-button.vue +556 -556
  19. package/components/u-calendar/types.ts +63 -63
  20. package/components/u-calendar/u-calendar.vue +592 -592
  21. package/components/u-car-keyboard/types.ts +12 -12
  22. package/components/u-car-keyboard/u-car-keyboard.vue +234 -234
  23. package/components/u-card/types.ts +59 -59
  24. package/components/u-card/u-card.vue +194 -194
  25. package/components/u-cell-group/types.ts +17 -17
  26. package/components/u-cell-group/u-cell-group.vue +50 -50
  27. package/components/u-cell-item/types.ts +54 -54
  28. package/components/u-cell-item/u-cell-item.vue +202 -202
  29. package/components/u-checkbox/types.ts +31 -31
  30. package/components/u-checkbox/u-checkbox.vue +267 -267
  31. package/components/u-checkbox-group/types.ts +32 -32
  32. package/components/u-checkbox-group/u-checkbox-group.vue +79 -79
  33. package/components/u-circle-progress/types.ts +52 -52
  34. package/components/u-circle-progress/u-circle-progress.vue +187 -187
  35. package/components/u-city-select/types.ts +20 -20
  36. package/components/u-city-select/u-city-select.vue +236 -236
  37. package/components/u-col/types.ts +30 -30
  38. package/components/u-col/u-col.vue +123 -123
  39. package/components/u-collapse/types.ts +31 -31
  40. package/components/u-collapse/u-collapse.vue +68 -68
  41. package/components/u-collapse-item/types.ts +25 -25
  42. package/components/u-collapse-item/u-collapse-item.vue +194 -194
  43. package/components/u-column-notice/types.ts +48 -48
  44. package/components/u-column-notice/u-column-notice.vue +176 -176
  45. package/components/u-count-down/types.ts +42 -42
  46. package/components/u-count-down/u-count-down.vue +258 -258
  47. package/components/u-count-to/types.ts +32 -32
  48. package/components/u-count-to/u-count-to.vue +241 -241
  49. package/components/u-divider/types.ts +31 -31
  50. package/components/u-divider/u-divider.vue +121 -121
  51. package/components/u-dropdown/types.ts +32 -32
  52. package/components/u-dropdown/u-dropdown.vue +289 -289
  53. package/components/u-dropdown-item/types.ts +27 -27
  54. package/components/u-dropdown-item/u-dropdown-item.vue +123 -123
  55. package/components/u-empty/types.ts +36 -36
  56. package/components/u-empty/u-empty.vue +88 -88
  57. package/components/u-field/types.ts +69 -69
  58. package/components/u-field/u-field.vue +354 -354
  59. package/components/u-form/u-form.vue +132 -132
  60. package/components/u-form-item/u-form-item.vue +417 -417
  61. package/components/u-full-screen/types.ts +14 -14
  62. package/components/u-full-screen/u-full-screen.vue +82 -82
  63. package/components/u-gap/types.ts +18 -18
  64. package/components/u-gap/u-gap.vue +40 -40
  65. package/components/u-grid/types.ts +19 -19
  66. package/components/u-grid/u-grid.vue +93 -93
  67. package/components/u-grid-item/types.ts +16 -16
  68. package/components/u-grid-item/u-grid-item.vue +130 -130
  69. package/components/u-icon/types.ts +62 -62
  70. package/components/u-icon/u-icon.vue +274 -274
  71. package/components/u-image/types.ts +51 -51
  72. package/components/u-image/u-image.vue +222 -222
  73. package/components/u-index-anchor/types.ts +16 -16
  74. package/components/u-index-anchor/u-index-anchor.vue +86 -86
  75. package/components/u-index-list/types.ts +43 -43
  76. package/components/u-index-list/u-index-list.vue +355 -355
  77. package/components/u-input/types.ts +140 -140
  78. package/components/u-input/u-input.vue +264 -255
  79. package/components/u-keyboard/types.ts +40 -40
  80. package/components/u-keyboard/u-keyboard.vue +158 -158
  81. package/components/u-lazy-load/types.ts +37 -37
  82. package/components/u-lazy-load/u-lazy-load.vue +233 -233
  83. package/components/u-line/types.ts +44 -44
  84. package/components/u-line/u-line.vue +59 -59
  85. package/components/u-line-progress/types.ts +58 -58
  86. package/components/u-line-progress/u-line-progress.vue +109 -109
  87. package/components/u-link/types.ts +43 -43
  88. package/components/u-link/u-link.vue +75 -75
  89. package/components/u-loading/types.ts +35 -35
  90. package/components/u-loading/u-loading.vue +90 -90
  91. package/components/u-loading-popup/types.ts +26 -26
  92. package/components/u-loading-popup/u-loading-popup.vue +239 -239
  93. package/components/u-loadmore/types.ts +79 -79
  94. package/components/u-loadmore/u-loadmore.vue +140 -140
  95. package/components/u-mask/types.ts +43 -43
  96. package/components/u-mask/u-mask.vue +106 -106
  97. package/components/u-message-input/types.ts +74 -74
  98. package/components/u-message-input/u-message-input.vue +255 -255
  99. package/components/u-modal/types.ts +118 -118
  100. package/components/u-modal/u-modal.vue +204 -204
  101. package/components/u-navbar/types.ts +103 -103
  102. package/components/u-navbar/u-navbar.vue +226 -226
  103. package/components/u-no-network/image.ts +2 -2
  104. package/components/u-no-network/types.ts +28 -28
  105. package/components/u-no-network/u-no-network.vue +290 -290
  106. package/components/u-notice-bar/types.ts +111 -111
  107. package/components/u-notice-bar/u-notice-bar.vue +174 -174
  108. package/components/u-number-box/types.ts +42 -42
  109. package/components/u-number-box/u-number-box.vue +312 -312
  110. package/components/u-number-keyboard/types.ts +26 -26
  111. package/components/u-number-keyboard/u-number-keyboard.vue +166 -166
  112. package/components/u-picker/types.ts +123 -123
  113. package/components/u-picker/u-picker.vue +637 -637
  114. package/components/u-popup/types.ts +59 -59
  115. package/components/u-popup/u-popup.vue +359 -359
  116. package/components/u-radio/types.ts +25 -25
  117. package/components/u-radio/u-radio.vue +258 -258
  118. package/components/u-radio-group/types.ts +29 -29
  119. package/components/u-radio-group/u-radio-group.vue +98 -98
  120. package/components/u-rate/types.ts +40 -40
  121. package/components/u-rate/u-rate.vue +234 -234
  122. package/components/u-read-more/types.ts +35 -35
  123. package/components/u-read-more/u-read-more.vue +150 -150
  124. package/components/u-row/types.ts +20 -20
  125. package/components/u-row/u-row.vue +87 -87
  126. package/components/u-row-notice/types.ts +39 -39
  127. package/components/u-row-notice/u-row-notice.vue +213 -213
  128. package/components/u-safe-bottom/u-safe-bottom.vue +46 -46
  129. package/components/u-search/types.ts +53 -53
  130. package/components/u-search/u-search.vue +256 -256
  131. package/components/u-section/types.ts +32 -32
  132. package/components/u-section/u-section.vue +125 -125
  133. package/components/u-select/types.ts +43 -43
  134. package/components/u-select/u-select.vue +361 -361
  135. package/components/u-skeleton/types.ts +20 -20
  136. package/components/u-skeleton/u-skeleton.vue +205 -205
  137. package/components/u-slider/types.ts +32 -32
  138. package/components/u-slider/u-slider.vue +238 -238
  139. package/components/u-status-bar/u-status-bar.vue +65 -65
  140. package/components/u-steps/types.ts +28 -28
  141. package/components/u-steps/u-steps.vue +160 -160
  142. package/components/u-sticky/types.ts +22 -22
  143. package/components/u-sticky/u-sticky.vue +159 -159
  144. package/components/u-subsection/types.ts +36 -36
  145. package/components/u-subsection/u-subsection.vue +328 -328
  146. package/components/u-swipe-action/types.ts +50 -50
  147. package/components/u-swipe-action/u-swipe-action.vue +253 -253
  148. package/components/u-swiper/types.ts +47 -47
  149. package/components/u-swiper/u-swiper.vue +266 -266
  150. package/components/u-switch/types.ts +28 -28
  151. package/components/u-switch/u-switch.vue +136 -136
  152. package/components/u-tabbar/types.ts +36 -36
  153. package/components/u-tabbar/u-tabbar.vue +280 -280
  154. package/components/u-table/types.ts +25 -25
  155. package/components/u-table/u-table.vue +55 -55
  156. package/components/u-tabs/types.ts +51 -51
  157. package/components/u-tabs/u-tabs.vue +284 -284
  158. package/components/u-tabs-swiper/types.ts +53 -53
  159. package/components/u-tabs-swiper/u-tabs-swiper.vue +379 -379
  160. package/components/u-tag/types.ts +37 -37
  161. package/components/u-tag/u-tag.vue +244 -244
  162. package/components/u-td/types.ts +12 -12
  163. package/components/u-td/u-td.vue +87 -87
  164. package/components/u-th/types.ts +12 -12
  165. package/components/u-th/u-th.vue +81 -81
  166. package/components/u-time-line/u-time-line.vue +39 -39
  167. package/components/u-time-line-item/types.ts +14 -14
  168. package/components/u-time-line-item/u-time-line-item.vue +78 -78
  169. package/components/u-toast/types.ts +36 -36
  170. package/components/u-toast/u-toast.vue +233 -233
  171. package/components/u-top-tips/types.ts +14 -14
  172. package/components/u-top-tips/u-top-tips.vue +113 -113
  173. package/components/u-tr/types.ts +8 -8
  174. package/components/u-tr/u-tr.vue +24 -24
  175. package/components/u-upload/types.ts +74 -74
  176. package/components/u-upload/u-upload.vue +545 -545
  177. package/components/u-verification-code/types.ts +22 -22
  178. package/components/u-verification-code/u-verification-code.vue +164 -164
  179. package/components/u-waterfall/types.ts +16 -16
  180. package/components/u-waterfall/u-waterfall.vue +175 -175
  181. package/iconfont.css +912 -912
  182. package/index.scss +23 -23
  183. package/index.ts +202 -204
  184. package/libs/config/config.ts +26 -26
  185. package/libs/config/zIndex.ts +37 -37
  186. package/libs/css/color.scss +155 -155
  187. package/libs/css/common.scss +178 -178
  188. package/libs/css/style.components.scss +7 -7
  189. package/libs/css/style.h5.scss +8 -8
  190. package/libs/css/style.mp.scss +72 -72
  191. package/libs/css/style.nvue.scss +3 -3
  192. package/libs/css/style.vue.scss +177 -177
  193. package/libs/function/$parent.ts +21 -21
  194. package/libs/function/addUnit.ts +13 -13
  195. package/libs/function/color.ts +37 -71
  196. package/libs/function/colorGradient.ts +125 -125
  197. package/libs/function/debounce.ts +28 -28
  198. package/libs/function/deepClone.ts +39 -39
  199. package/libs/function/deepMerge.ts +34 -34
  200. package/libs/function/getParent.ts +59 -59
  201. package/libs/function/getRect.ts +26 -26
  202. package/libs/function/guid.ts +42 -42
  203. package/libs/function/md5.ts +391 -391
  204. package/libs/function/parent.ts +21 -21
  205. package/libs/function/queryParams.ts +60 -60
  206. package/libs/function/random.ts +16 -16
  207. package/libs/function/randomArray.ts +11 -11
  208. package/libs/function/route.ts +118 -118
  209. package/libs/function/styleUtils.ts +83 -83
  210. package/libs/function/sys.ts +15 -15
  211. package/libs/function/test.ts +229 -229
  212. package/libs/function/throttle.ts +31 -31
  213. package/libs/function/timeFormat.ts +54 -54
  214. package/libs/function/timeFrom.ts +48 -48
  215. package/libs/function/toast.ts +14 -14
  216. package/libs/function/trim.ts +21 -21
  217. package/libs/function/type2icon.ts +36 -36
  218. package/libs/hooks/useEmitter.ts +77 -77
  219. package/libs/hooks/useParent.ts +29 -29
  220. package/libs/request/auto-http.ts +76 -76
  221. package/libs/request/index.ts +223 -223
  222. package/libs/store/index.ts +88 -88
  223. package/libs/util/area.ts +3771 -3771
  224. package/libs/util/async-validator.d.ts +62 -62
  225. package/libs/util/async-validator.js +1368 -1368
  226. package/libs/util/city.ts +432 -432
  227. package/libs/util/emitter.ts +102 -102
  228. package/libs/util/mitt.ts +115 -115
  229. package/libs/util/parent.ts +20 -20
  230. package/libs/util/province.ts +37 -37
  231. package/package.json +1 -1
  232. package/readme.md +237 -237
  233. package/theme.scss +38 -38
  234. package/types/components.d.ts +95 -95
  235. package/types/global.d.ts +255 -221
  236. package/types/ignore-errors.d.ts +30 -30
  237. package/types/index.d.ts +90 -90
  238. package/types/uni-app.d.ts +63 -63
@@ -1,1368 +1,1368 @@
1
- // @ts-nocheck
2
- function _extends() {
3
- _extends =
4
- Object.assign ||
5
- function (target) {
6
- for (var i = 1; i < arguments.length; i++) {
7
- var source = arguments[i];
8
-
9
- for (var key in source) {
10
- if (Object.prototype.hasOwnProperty.call(source, key)) {
11
- target[key] = source[key];
12
- }
13
- }
14
- }
15
-
16
- return target;
17
- };
18
-
19
- return _extends.apply(this, arguments);
20
- }
21
-
22
- /* eslint no-console:0 */
23
- var formatRegExp = /%[sdj%]/g;
24
- var warning = function warning() {}; // don't print warning message when in production env or node runtime
25
-
26
- if (typeof process !== 'undefined' && process.env && process.env.NODE_ENV !== 'production' && typeof window !== 'undefined' && typeof document !== 'undefined') {
27
- warning = function warning(type, errors) {
28
- if (typeof console !== 'undefined' && console.warn) {
29
- if (
30
- errors.every(function (e) {
31
- return typeof e === 'string';
32
- })
33
- ) {
34
- console.warn(type, errors);
35
- }
36
- }
37
- };
38
- }
39
-
40
- function convertFieldsError(errors) {
41
- if (!errors || !errors.length) return null;
42
- var fields = {};
43
- errors.forEach(function (error) {
44
- var field = error.field;
45
- fields[field] = fields[field] || [];
46
- fields[field].push(error);
47
- });
48
- return fields;
49
- }
50
-
51
- function format() {
52
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
53
- args[_key] = arguments[_key];
54
- }
55
-
56
- var i = 1;
57
- var f = args[0];
58
- var len = args.length;
59
-
60
- if (typeof f === 'function') {
61
- return f.apply(null, args.slice(1));
62
- }
63
-
64
- if (typeof f === 'string') {
65
- var str = String(f).replace(formatRegExp, function (x) {
66
- if (x === '%%') {
67
- return '%';
68
- }
69
-
70
- if (i >= len) {
71
- return x;
72
- }
73
-
74
- switch (x) {
75
- case '%s':
76
- return String(args[i++]);
77
-
78
- case '%d':
79
- return Number(args[i++]);
80
-
81
- case '%j':
82
- try {
83
- return JSON.stringify(args[i++]);
84
- } catch (_) {
85
- return '[Circular]';
86
- }
87
-
88
- break;
89
-
90
- default:
91
- return x;
92
- }
93
- });
94
-
95
- for (var arg = args[i]; i < len; arg = args[++i]) {
96
- str += ' ' + arg;
97
- }
98
-
99
- return str;
100
- }
101
-
102
- return f;
103
- }
104
-
105
- function isNativeStringType(type) {
106
- return type === 'string' || type === 'url' || type === 'hex' || type === 'email' || type === 'pattern';
107
- }
108
-
109
- function isEmptyValue(value, type) {
110
- if (value === undefined || value === null) {
111
- return true;
112
- }
113
-
114
- if (type === 'array' && Array.isArray(value) && !value.length) {
115
- return true;
116
- }
117
-
118
- if (isNativeStringType(type) && typeof value === 'string' && !value) {
119
- return true;
120
- }
121
-
122
- return false;
123
- }
124
-
125
- function asyncParallelArray(arr, func, callback) {
126
- var results = [];
127
- var total = 0;
128
- var arrLength = arr.length;
129
-
130
- function count(errors) {
131
- results.push.apply(results, errors);
132
- total++;
133
-
134
- if (total === arrLength) {
135
- callback(results);
136
- }
137
- }
138
-
139
- arr.forEach(function (a) {
140
- func(a, count);
141
- });
142
- }
143
-
144
- function asyncSerialArray(arr, func, callback) {
145
- var index = 0;
146
- var arrLength = arr.length;
147
-
148
- function next(errors) {
149
- if (errors && errors.length) {
150
- callback(errors);
151
- return;
152
- }
153
-
154
- var original = index;
155
- index = index + 1;
156
-
157
- if (original < arrLength) {
158
- func(arr[original], next);
159
- } else {
160
- callback([]);
161
- }
162
- }
163
-
164
- next([]);
165
- }
166
-
167
- function flattenObjArr(objArr) {
168
- var ret = [];
169
- Object.keys(objArr).forEach(function (k) {
170
- ret.push.apply(ret, objArr[k]);
171
- });
172
- return ret;
173
- }
174
-
175
- function asyncMap(objArr, option, func, callback) {
176
- if (option.first) {
177
- var _pending = new Promise(function (resolve, reject) {
178
- var next = function next(errors) {
179
- callback(errors);
180
- return errors.length
181
- ? reject({
182
- errors: errors,
183
- fields: convertFieldsError(errors)
184
- })
185
- : resolve();
186
- };
187
-
188
- var flattenArr = flattenObjArr(objArr);
189
- asyncSerialArray(flattenArr, func, next);
190
- });
191
-
192
- _pending['catch'](function (e) {
193
- return e;
194
- });
195
-
196
- return _pending;
197
- }
198
-
199
- var firstFields = option.firstFields || [];
200
-
201
- if (firstFields === true) {
202
- firstFields = Object.keys(objArr);
203
- }
204
-
205
- var objArrKeys = Object.keys(objArr);
206
- var objArrLength = objArrKeys.length;
207
- var total = 0;
208
- var results = [];
209
- var pending = new Promise(function (resolve, reject) {
210
- var next = function next(errors) {
211
- results.push.apply(results, errors);
212
- total++;
213
-
214
- if (total === objArrLength) {
215
- callback(results);
216
- return results.length
217
- ? reject({
218
- errors: results,
219
- fields: convertFieldsError(results)
220
- })
221
- : resolve();
222
- }
223
- };
224
-
225
- if (!objArrKeys.length) {
226
- callback(results);
227
- resolve();
228
- }
229
-
230
- objArrKeys.forEach(function (key) {
231
- var arr = objArr[key];
232
-
233
- if (firstFields.indexOf(key) !== -1) {
234
- asyncSerialArray(arr, func, next);
235
- } else {
236
- asyncParallelArray(arr, func, next);
237
- }
238
- });
239
- });
240
- pending['catch'](function (e) {
241
- return e;
242
- });
243
- return pending;
244
- }
245
-
246
- function complementError(rule) {
247
- return function (oe) {
248
- if (oe && oe.message) {
249
- oe.field = oe.field || rule.fullField;
250
- return oe;
251
- }
252
-
253
- return {
254
- message: typeof oe === 'function' ? oe() : oe,
255
- field: oe.field || rule.fullField
256
- };
257
- };
258
- }
259
-
260
- function deepMerge(target, source) {
261
- if (source) {
262
- for (var s in source) {
263
- if (source.hasOwnProperty(s)) {
264
- var value = source[s];
265
-
266
- if (typeof value === 'object' && typeof target[s] === 'object') {
267
- target[s] = _extends({}, target[s], {}, value);
268
- } else {
269
- target[s] = value;
270
- }
271
- }
272
- }
273
- }
274
-
275
- return target;
276
- }
277
-
278
- /**
279
- * Rule for validating required fields.
280
- *
281
- * @param rule The validation rule.
282
- * @param value The value of the field on the source object.
283
- * @param source The source object being validated.
284
- * @param errors An array of errors that this rule may add
285
- * validation errors to.
286
- * @param options The validation options.
287
- * @param options.messages The validation messages.
288
- */
289
-
290
- function required(rule, value, source, errors, options, type) {
291
- if (rule.required && (!source.hasOwnProperty(rule.field) || isEmptyValue(value, type || rule.type))) {
292
- errors.push(format(options.messages.required, rule.fullField));
293
- }
294
- }
295
-
296
- /**
297
- * Rule for validating whitespace.
298
- *
299
- * @param rule The validation rule.
300
- * @param value The value of the field on the source object.
301
- * @param source The source object being validated.
302
- * @param errors An array of errors that this rule may add
303
- * validation errors to.
304
- * @param options The validation options.
305
- * @param options.messages The validation messages.
306
- */
307
-
308
- function whitespace(rule, value, source, errors, options) {
309
- if (/^\s+$/.test(value) || value === '') {
310
- errors.push(format(options.messages.whitespace, rule.fullField));
311
- }
312
- }
313
-
314
- /* eslint max-len:0 */
315
-
316
- var pattern = {
317
- // http://emailregex.com/
318
- 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,}))$/,
319
- url: new RegExp(
320
- '^(?!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]*)?$',
321
- 'i'
322
- ),
323
- hex: /^#?([a-f0-9]{6}|[a-f0-9]{3})$/i
324
- };
325
- var types = {
326
- integer: function integer(value) {
327
- return types.number(value) && parseInt(value, 10) === value;
328
- },
329
- float: function float(value) {
330
- return types.number(value) && !types.integer(value);
331
- },
332
- array: function array(value) {
333
- return Array.isArray(value);
334
- },
335
- regexp: function regexp(value) {
336
- if (value instanceof RegExp) {
337
- return true;
338
- }
339
-
340
- try {
341
- return !!new RegExp(value);
342
- } catch (e) {
343
- return false;
344
- }
345
- },
346
- date: function date(value) {
347
- return typeof value.getTime === 'function' && typeof value.getMonth === 'function' && typeof value.getYear === 'function';
348
- },
349
- number: function number(value) {
350
- if (isNaN(value)) {
351
- return false;
352
- }
353
-
354
- // 修改源码,将字符串数值先转为数值
355
- return typeof +value === 'number';
356
- },
357
- object: function object(value) {
358
- return typeof value === 'object' && !types.array(value);
359
- },
360
- method: function method(value) {
361
- return typeof value === 'function';
362
- },
363
- email: function email(value) {
364
- return typeof value === 'string' && !!value.match(pattern.email) && value.length < 255;
365
- },
366
- url: function url(value) {
367
- return typeof value === 'string' && !!value.match(pattern.url);
368
- },
369
- hex: function hex(value) {
370
- return typeof value === 'string' && !!value.match(pattern.hex);
371
- }
372
- };
373
- /**
374
- * Rule for validating the type of a value.
375
- *
376
- * @param rule The validation rule.
377
- * @param value The value of the field on the source object.
378
- * @param source The source object being validated.
379
- * @param errors An array of errors that this rule may add
380
- * validation errors to.
381
- * @param options The validation options.
382
- * @param options.messages The validation messages.
383
- */
384
-
385
- function type(rule, value, source, errors, options) {
386
- if (rule.required && value === undefined) {
387
- required(rule, value, source, errors, options);
388
- return;
389
- }
390
-
391
- var custom = ['integer', 'float', 'array', 'regexp', 'object', 'method', 'email', 'number', 'date', 'url', 'hex'];
392
- var ruleType = rule.type;
393
-
394
- if (custom.indexOf(ruleType) > -1) {
395
- if (!types[ruleType](value)) {
396
- errors.push(format(options.messages.types[ruleType], rule.fullField, rule.type));
397
- } // straight typeof check
398
- } else if (ruleType && typeof value !== rule.type) {
399
- errors.push(format(options.messages.types[ruleType], rule.fullField, rule.type));
400
- }
401
- }
402
-
403
- /**
404
- * Rule for validating minimum and maximum allowed values.
405
- *
406
- * @param rule The validation rule.
407
- * @param value The value of the field on the source object.
408
- * @param source The source object being validated.
409
- * @param errors An array of errors that this rule may add
410
- * validation errors to.
411
- * @param options The validation options.
412
- * @param options.messages The validation messages.
413
- */
414
-
415
- function range(rule, value, source, errors, options) {
416
- var len = typeof rule.len === 'number';
417
- var min = typeof rule.min === 'number';
418
- var max = typeof rule.max === 'number'; // 正则匹配码点范围从U+010000一直到U+10FFFF的文字(补充平面Supplementary Plane)
419
-
420
- var spRegexp = /[\uD800-\uDBFF][\uDC00-\uDFFF]/g;
421
- var val = value;
422
- var key = null;
423
- var num = typeof value === 'number';
424
- var str = typeof value === 'string';
425
- var arr = Array.isArray(value);
426
-
427
- if (num) {
428
- key = 'number';
429
- } else if (str) {
430
- key = 'string';
431
- } else if (arr) {
432
- key = 'array';
433
- } // if the value is not of a supported type for range validation
434
- // the validation rule rule should use the
435
- // type property to also test for a particular type
436
-
437
- if (!key) {
438
- return false;
439
- }
440
-
441
- if (arr) {
442
- val = value.length;
443
- }
444
-
445
- if (str) {
446
- // 处理码点大于U+010000的文字length属性不准确的bug,如"𠮷𠮷𠮷".length !== 3
447
- val = value.replace(spRegexp, '_').length;
448
- }
449
-
450
- if (len) {
451
- if (val !== rule.len) {
452
- errors.push(format(options.messages[key].len, rule.fullField, rule.len));
453
- }
454
- } else if (min && !max && val < rule.min) {
455
- errors.push(format(options.messages[key].min, rule.fullField, rule.min));
456
- } else if (max && !min && val > rule.max) {
457
- errors.push(format(options.messages[key].max, rule.fullField, rule.max));
458
- } else if (min && max && (val < rule.min || val > rule.max)) {
459
- errors.push(format(options.messages[key].range, rule.fullField, rule.min, rule.max));
460
- }
461
- }
462
-
463
- var ENUM = 'enum';
464
- /**
465
- * Rule for validating a value exists in an enumerable list.
466
- *
467
- * @param rule The validation rule.
468
- * @param value The value of the field on the source object.
469
- * @param source The source object being validated.
470
- * @param errors An array of errors that this rule may add
471
- * validation errors to.
472
- * @param options The validation options.
473
- * @param options.messages The validation messages.
474
- */
475
-
476
- function enumerable(rule, value, source, errors, options) {
477
- rule[ENUM] = Array.isArray(rule[ENUM]) ? rule[ENUM] : [];
478
-
479
- if (rule[ENUM].indexOf(value) === -1) {
480
- errors.push(format(options.messages[ENUM], rule.fullField, rule[ENUM].join(', ')));
481
- }
482
- }
483
-
484
- /**
485
- * Rule for validating a regular expression pattern.
486
- *
487
- * @param rule The validation rule.
488
- * @param value The value of the field on the source object.
489
- * @param source The source object being validated.
490
- * @param errors An array of errors that this rule may add
491
- * validation errors to.
492
- * @param options The validation options.
493
- * @param options.messages The validation messages.
494
- */
495
-
496
- function pattern$1(rule, value, source, errors, options) {
497
- if (rule.pattern) {
498
- if (rule.pattern instanceof RegExp) {
499
- // if a RegExp instance is passed, reset `lastIndex` in case its `global`
500
- // flag is accidentally set to `true`, which in a validation scenario
501
- // is not necessary and the result might be misleading
502
- rule.pattern.lastIndex = 0;
503
-
504
- if (!rule.pattern.test(value)) {
505
- errors.push(format(options.messages.pattern.mismatch, rule.fullField, value, rule.pattern));
506
- }
507
- } else if (typeof rule.pattern === 'string') {
508
- var _pattern = new RegExp(rule.pattern);
509
-
510
- if (!_pattern.test(value)) {
511
- errors.push(format(options.messages.pattern.mismatch, rule.fullField, value, rule.pattern));
512
- }
513
- }
514
- }
515
- }
516
-
517
- var rules = {
518
- required: required,
519
- whitespace: whitespace,
520
- type: type,
521
- range: range,
522
- enum: enumerable,
523
- pattern: pattern$1
524
- };
525
-
526
- /**
527
- * Performs validation for string types.
528
- *
529
- * @param rule The validation rule.
530
- * @param value The value of the field on the source object.
531
- * @param callback The callback function.
532
- * @param source The source object being validated.
533
- * @param options The validation options.
534
- * @param options.messages The validation messages.
535
- */
536
-
537
- function string(rule, value, callback, source, options) {
538
- var errors = [];
539
- var validate = rule.required || (!rule.required && source.hasOwnProperty(rule.field));
540
-
541
- if (validate) {
542
- if (isEmptyValue(value, 'string') && !rule.required) {
543
- return callback();
544
- }
545
-
546
- rules.required(rule, value, source, errors, options, 'string');
547
-
548
- if (!isEmptyValue(value, 'string')) {
549
- rules.type(rule, value, source, errors, options);
550
- rules.range(rule, value, source, errors, options);
551
- rules.pattern(rule, value, source, errors, options);
552
-
553
- if (rule.whitespace === true) {
554
- rules.whitespace(rule, value, source, errors, options);
555
- }
556
- }
557
- }
558
-
559
- callback(errors);
560
- }
561
-
562
- /**
563
- * Validates a function.
564
- *
565
- * @param rule The validation rule.
566
- * @param value The value of the field on the source object.
567
- * @param callback The callback function.
568
- * @param source The source object being validated.
569
- * @param options The validation options.
570
- * @param options.messages The validation messages.
571
- */
572
-
573
- function method(rule, value, callback, source, options) {
574
- var errors = [];
575
- var validate = rule.required || (!rule.required && source.hasOwnProperty(rule.field));
576
-
577
- if (validate) {
578
- if (isEmptyValue(value) && !rule.required) {
579
- return callback();
580
- }
581
-
582
- rules.required(rule, value, source, errors, options);
583
-
584
- if (value !== undefined) {
585
- rules.type(rule, value, source, errors, options);
586
- }
587
- }
588
-
589
- callback(errors);
590
- }
591
-
592
- /**
593
- * Validates a number.
594
- *
595
- * @param rule The validation rule.
596
- * @param value The value of the field on the source object.
597
- * @param callback The callback function.
598
- * @param source The source object being validated.
599
- * @param options The validation options.
600
- * @param options.messages The validation messages.
601
- */
602
-
603
- function number(rule, value, callback, source, options) {
604
- var errors = [];
605
- var validate = rule.required || (!rule.required && source.hasOwnProperty(rule.field));
606
-
607
- if (validate) {
608
- if (value === '') {
609
- value = undefined;
610
- }
611
-
612
- if (isEmptyValue(value) && !rule.required) {
613
- return callback();
614
- }
615
-
616
- rules.required(rule, value, source, errors, options);
617
-
618
- if (value !== undefined) {
619
- rules.type(rule, value, source, errors, options);
620
- rules.range(rule, value, source, errors, options);
621
- }
622
- }
623
-
624
- callback(errors);
625
- }
626
-
627
- /**
628
- * Validates a boolean.
629
- *
630
- * @param rule The validation rule.
631
- * @param value The value of the field on the source object.
632
- * @param callback The callback function.
633
- * @param source The source object being validated.
634
- * @param options The validation options.
635
- * @param options.messages The validation messages.
636
- */
637
-
638
- function _boolean(rule, value, callback, source, options) {
639
- var errors = [];
640
- var validate = rule.required || (!rule.required && source.hasOwnProperty(rule.field));
641
-
642
- if (validate) {
643
- if (isEmptyValue(value) && !rule.required) {
644
- return callback();
645
- }
646
-
647
- rules.required(rule, value, source, errors, options);
648
-
649
- if (value !== undefined) {
650
- rules.type(rule, value, source, errors, options);
651
- }
652
- }
653
-
654
- callback(errors);
655
- }
656
-
657
- /**
658
- * Validates the regular expression type.
659
- *
660
- * @param rule The validation rule.
661
- * @param value The value of the field on the source object.
662
- * @param callback The callback function.
663
- * @param source The source object being validated.
664
- * @param options The validation options.
665
- * @param options.messages The validation messages.
666
- */
667
-
668
- function regexp(rule, value, callback, source, options) {
669
- var errors = [];
670
- var validate = rule.required || (!rule.required && source.hasOwnProperty(rule.field));
671
-
672
- if (validate) {
673
- if (isEmptyValue(value) && !rule.required) {
674
- return callback();
675
- }
676
-
677
- rules.required(rule, value, source, errors, options);
678
-
679
- if (!isEmptyValue(value)) {
680
- rules.type(rule, value, source, errors, options);
681
- }
682
- }
683
-
684
- callback(errors);
685
- }
686
-
687
- /**
688
- * Validates a number is an integer.
689
- *
690
- * @param rule The validation rule.
691
- * @param value The value of the field on the source object.
692
- * @param callback The callback function.
693
- * @param source The source object being validated.
694
- * @param options The validation options.
695
- * @param options.messages The validation messages.
696
- */
697
-
698
- function integer(rule, value, callback, source, options) {
699
- var errors = [];
700
- var validate = rule.required || (!rule.required && source.hasOwnProperty(rule.field));
701
-
702
- if (validate) {
703
- if (isEmptyValue(value) && !rule.required) {
704
- return callback();
705
- }
706
-
707
- rules.required(rule, value, source, errors, options);
708
-
709
- if (value !== undefined) {
710
- rules.type(rule, value, source, errors, options);
711
- rules.range(rule, value, source, errors, options);
712
- }
713
- }
714
-
715
- callback(errors);
716
- }
717
-
718
- /**
719
- * Validates a number is a floating point number.
720
- *
721
- * @param rule The validation rule.
722
- * @param value The value of the field on the source object.
723
- * @param callback The callback function.
724
- * @param source The source object being validated.
725
- * @param options The validation options.
726
- * @param options.messages The validation messages.
727
- */
728
-
729
- function floatFn(rule, value, callback, source, options) {
730
- var errors = [];
731
- var validate = rule.required || (!rule.required && source.hasOwnProperty(rule.field));
732
-
733
- if (validate) {
734
- if (isEmptyValue(value) && !rule.required) {
735
- return callback();
736
- }
737
-
738
- rules.required(rule, value, source, errors, options);
739
-
740
- if (value !== undefined) {
741
- rules.type(rule, value, source, errors, options);
742
- rules.range(rule, value, source, errors, options);
743
- }
744
- }
745
-
746
- callback(errors);
747
- }
748
-
749
- /**
750
- * Validates an array.
751
- *
752
- * @param rule The validation rule.
753
- * @param value The value of the field on the source object.
754
- * @param callback The callback function.
755
- * @param source The source object being validated.
756
- * @param options The validation options.
757
- * @param options.messages The validation messages.
758
- */
759
-
760
- function array(rule, value, callback, source, options) {
761
- var errors = [];
762
- var validate = rule.required || (!rule.required && source.hasOwnProperty(rule.field));
763
-
764
- if (validate) {
765
- if (isEmptyValue(value, 'array') && !rule.required) {
766
- return callback();
767
- }
768
-
769
- rules.required(rule, value, source, errors, options, 'array');
770
-
771
- if (!isEmptyValue(value, 'array')) {
772
- rules.type(rule, value, source, errors, options);
773
- rules.range(rule, value, source, errors, options);
774
- }
775
- }
776
-
777
- callback(errors);
778
- }
779
-
780
- /**
781
- * Validates an object.
782
- *
783
- * @param rule The validation rule.
784
- * @param value The value of the field on the source object.
785
- * @param callback The callback function.
786
- * @param source The source object being validated.
787
- * @param options The validation options.
788
- * @param options.messages The validation messages.
789
- */
790
-
791
- function object(rule, value, callback, source, options) {
792
- var errors = [];
793
- var validate = rule.required || (!rule.required && source.hasOwnProperty(rule.field));
794
-
795
- if (validate) {
796
- if (isEmptyValue(value) && !rule.required) {
797
- return callback();
798
- }
799
-
800
- rules.required(rule, value, source, errors, options);
801
-
802
- if (value !== undefined) {
803
- rules.type(rule, value, source, errors, options);
804
- }
805
- }
806
-
807
- callback(errors);
808
- }
809
-
810
- var ENUM$1 = 'enum';
811
- /**
812
- * Validates an enumerable list.
813
- *
814
- * @param rule The validation rule.
815
- * @param value The value of the field on the source object.
816
- * @param callback The callback function.
817
- * @param source The source object being validated.
818
- * @param options The validation options.
819
- * @param options.messages The validation messages.
820
- */
821
-
822
- function enumerable$1(rule, value, callback, source, options) {
823
- var errors = [];
824
- var validate = rule.required || (!rule.required && source.hasOwnProperty(rule.field));
825
-
826
- if (validate) {
827
- if (isEmptyValue(value) && !rule.required) {
828
- return callback();
829
- }
830
-
831
- rules.required(rule, value, source, errors, options);
832
-
833
- if (value !== undefined) {
834
- rules[ENUM$1](rule, value, source, errors, options);
835
- }
836
- }
837
-
838
- callback(errors);
839
- }
840
-
841
- /**
842
- * Validates a regular expression pattern.
843
- *
844
- * Performs validation when a rule only contains
845
- * a pattern property but is not declared as a string type.
846
- *
847
- * @param rule The validation rule.
848
- * @param value The value of the field on the source object.
849
- * @param callback The callback function.
850
- * @param source The source object being validated.
851
- * @param options The validation options.
852
- * @param options.messages The validation messages.
853
- */
854
-
855
- function pattern$2(rule, value, callback, source, options) {
856
- var errors = [];
857
- var validate = rule.required || (!rule.required && source.hasOwnProperty(rule.field));
858
-
859
- if (validate) {
860
- if (isEmptyValue(value, 'string') && !rule.required) {
861
- return callback();
862
- }
863
-
864
- rules.required(rule, value, source, errors, options);
865
-
866
- if (!isEmptyValue(value, 'string')) {
867
- rules.pattern(rule, value, source, errors, options);
868
- }
869
- }
870
-
871
- callback(errors);
872
- }
873
-
874
- function date(rule, value, callback, source, options) {
875
- var errors = [];
876
- var validate = rule.required || (!rule.required && source.hasOwnProperty(rule.field));
877
-
878
- if (validate) {
879
- if (isEmptyValue(value) && !rule.required) {
880
- return callback();
881
- }
882
-
883
- rules.required(rule, value, source, errors, options);
884
-
885
- if (!isEmptyValue(value)) {
886
- var dateObject;
887
-
888
- if (typeof value === 'number') {
889
- dateObject = new Date(value);
890
- } else {
891
- dateObject = value;
892
- }
893
-
894
- rules.type(rule, dateObject, source, errors, options);
895
-
896
- if (dateObject) {
897
- rules.range(rule, dateObject.getTime(), source, errors, options);
898
- }
899
- }
900
- }
901
-
902
- callback(errors);
903
- }
904
-
905
- function required$1(rule, value, callback, source, options) {
906
- var errors = [];
907
- var type = Array.isArray(value) ? 'array' : typeof value;
908
- rules.required(rule, value, source, errors, options, type);
909
- callback(errors);
910
- }
911
-
912
- function type$1(rule, value, callback, source, options) {
913
- var ruleType = rule.type;
914
- var errors = [];
915
- var validate = rule.required || (!rule.required && source.hasOwnProperty(rule.field));
916
-
917
- if (validate) {
918
- if (isEmptyValue(value, ruleType) && !rule.required) {
919
- return callback();
920
- }
921
-
922
- rules.required(rule, value, source, errors, options, ruleType);
923
-
924
- if (!isEmptyValue(value, ruleType)) {
925
- rules.type(rule, value, source, errors, options);
926
- }
927
- }
928
-
929
- callback(errors);
930
- }
931
-
932
- /**
933
- * Performs validation for any type.
934
- *
935
- * @param rule The validation rule.
936
- * @param value The value of the field on the source object.
937
- * @param callback The callback function.
938
- * @param source The source object being validated.
939
- * @param options The validation options.
940
- * @param options.messages The validation messages.
941
- */
942
-
943
- function any(rule, value, callback, source, options) {
944
- var errors = [];
945
- var validate = rule.required || (!rule.required && source.hasOwnProperty(rule.field));
946
-
947
- if (validate) {
948
- if (isEmptyValue(value) && !rule.required) {
949
- return callback();
950
- }
951
-
952
- rules.required(rule, value, source, errors, options);
953
- }
954
-
955
- callback(errors);
956
- }
957
-
958
- var validators = {
959
- string: string,
960
- method: method,
961
- number: number,
962
- boolean: _boolean,
963
- regexp: regexp,
964
- integer: integer,
965
- float: floatFn,
966
- array: array,
967
- object: object,
968
- enum: enumerable$1,
969
- pattern: pattern$2,
970
- date: date,
971
- url: type$1,
972
- hex: type$1,
973
- email: type$1,
974
- required: required$1,
975
- any: any
976
- };
977
-
978
- function newMessages() {
979
- return {
980
- default: 'Validation error on field %s',
981
- required: '%s is required',
982
- enum: '%s must be one of %s',
983
- whitespace: '%s cannot be empty',
984
- date: {
985
- format: '%s date %s is invalid for format %s',
986
- parse: '%s date could not be parsed, %s is invalid ',
987
- invalid: '%s date %s is invalid'
988
- },
989
- types: {
990
- string: '%s is not a %s',
991
- method: '%s is not a %s (function)',
992
- array: '%s is not an %s',
993
- object: '%s is not an %s',
994
- number: '%s is not a %s',
995
- date: '%s is not a %s',
996
- boolean: '%s is not a %s',
997
- integer: '%s is not an %s',
998
- float: '%s is not a %s',
999
- regexp: '%s is not a valid %s',
1000
- email: '%s is not a valid %s',
1001
- url: '%s is not a valid %s',
1002
- hex: '%s is not a valid %s'
1003
- },
1004
- string: {
1005
- len: '%s must be exactly %s characters',
1006
- min: '%s must be at least %s characters',
1007
- max: '%s cannot be longer than %s characters',
1008
- range: '%s must be between %s and %s characters'
1009
- },
1010
- number: {
1011
- len: '%s must equal %s',
1012
- min: '%s cannot be less than %s',
1013
- max: '%s cannot be greater than %s',
1014
- range: '%s must be between %s and %s'
1015
- },
1016
- array: {
1017
- len: '%s must be exactly %s in length',
1018
- min: '%s cannot be less than %s in length',
1019
- max: '%s cannot be greater than %s in length',
1020
- range: '%s must be between %s and %s in length'
1021
- },
1022
- pattern: {
1023
- mismatch: '%s value %s does not match pattern %s'
1024
- },
1025
- clone: function clone() {
1026
- var cloned = JSON.parse(JSON.stringify(this));
1027
- cloned.clone = this.clone;
1028
- return cloned;
1029
- }
1030
- };
1031
- }
1032
- var messages = newMessages();
1033
-
1034
- /**
1035
- * Encapsulates a validation schema.
1036
- *
1037
- * @param descriptor An object declaring validation rules
1038
- * for this schema.
1039
- */
1040
-
1041
- function Schema(descriptor) {
1042
- this.rules = null;
1043
- this._messages = messages;
1044
- this.define(descriptor);
1045
- }
1046
-
1047
- Schema.prototype = {
1048
- messages: function messages(_messages) {
1049
- if (_messages) {
1050
- this._messages = deepMerge(newMessages(), _messages);
1051
- }
1052
-
1053
- return this._messages;
1054
- },
1055
- define: function define(rules) {
1056
- if (!rules) {
1057
- throw new Error('Cannot configure a schema with no rules');
1058
- }
1059
-
1060
- if (typeof rules !== 'object' || Array.isArray(rules)) {
1061
- throw new Error('Rules must be an object');
1062
- }
1063
-
1064
- this.rules = {};
1065
- var z;
1066
- var item;
1067
-
1068
- for (z in rules) {
1069
- if (rules.hasOwnProperty(z)) {
1070
- item = rules[z];
1071
- this.rules[z] = Array.isArray(item) ? item : [item];
1072
- }
1073
- }
1074
- },
1075
- validate: function validate(source_, o, oc) {
1076
- var _this = this;
1077
-
1078
- if (o === void 0) {
1079
- o = {};
1080
- }
1081
-
1082
- if (oc === void 0) {
1083
- oc = function oc() {};
1084
- }
1085
-
1086
- var source = source_;
1087
- var options = o;
1088
- var callback = oc;
1089
-
1090
- if (typeof options === 'function') {
1091
- callback = options;
1092
- options = {};
1093
- }
1094
-
1095
- if (!this.rules || Object.keys(this.rules).length === 0) {
1096
- if (callback) {
1097
- callback();
1098
- }
1099
-
1100
- return Promise.resolve();
1101
- }
1102
-
1103
- function complete(results) {
1104
- var i;
1105
- var errors = [];
1106
- var fields = {};
1107
-
1108
- function add(e) {
1109
- if (Array.isArray(e)) {
1110
- var _errors;
1111
-
1112
- errors = (_errors = errors).concat.apply(_errors, e);
1113
- } else {
1114
- errors.push(e);
1115
- }
1116
- }
1117
-
1118
- for (i = 0; i < results.length; i++) {
1119
- add(results[i]);
1120
- }
1121
-
1122
- if (!errors.length) {
1123
- errors = null;
1124
- fields = null;
1125
- } else {
1126
- fields = convertFieldsError(errors);
1127
- }
1128
-
1129
- callback(errors, fields);
1130
- }
1131
-
1132
- if (options.messages) {
1133
- var messages$1 = this.messages();
1134
-
1135
- if (messages$1 === messages) {
1136
- messages$1 = newMessages();
1137
- }
1138
-
1139
- deepMerge(messages$1, options.messages);
1140
- options.messages = messages$1;
1141
- } else {
1142
- options.messages = this.messages();
1143
- }
1144
-
1145
- var arr;
1146
- var value;
1147
- var series = {};
1148
- var keys = options.keys || Object.keys(this.rules);
1149
- keys.forEach(function (z) {
1150
- arr = _this.rules[z];
1151
- value = source[z];
1152
- arr.forEach(function (r) {
1153
- var rule = r;
1154
-
1155
- if (typeof rule.transform === 'function') {
1156
- if (source === source_) {
1157
- source = _extends({}, source);
1158
- }
1159
-
1160
- value = source[z] = rule.transform(value);
1161
- }
1162
-
1163
- if (typeof rule === 'function') {
1164
- rule = {
1165
- validator: rule
1166
- };
1167
- } else {
1168
- rule = _extends({}, rule);
1169
- }
1170
-
1171
- rule.validator = _this.getValidationMethod(rule);
1172
- rule.field = z;
1173
- rule.fullField = rule.fullField || z;
1174
- rule.type = _this.getType(rule);
1175
-
1176
- if (!rule.validator) {
1177
- return;
1178
- }
1179
-
1180
- series[z] = series[z] || [];
1181
- series[z].push({
1182
- rule: rule,
1183
- value: value,
1184
- source: source,
1185
- field: z
1186
- });
1187
- });
1188
- });
1189
- var errorFields = {};
1190
- return asyncMap(
1191
- series,
1192
- options,
1193
- function (data, doIt) {
1194
- var rule = data.rule;
1195
- var deep = (rule.type === 'object' || rule.type === 'array') && (typeof rule.fields === 'object' || typeof rule.defaultField === 'object');
1196
- deep = deep && (rule.required || (!rule.required && data.value));
1197
- rule.field = data.field;
1198
-
1199
- function addFullfield(key, schema) {
1200
- return _extends({}, schema, {
1201
- fullField: rule.fullField + '.' + key
1202
- });
1203
- }
1204
-
1205
- function cb(e) {
1206
- if (e === void 0) {
1207
- e = [];
1208
- }
1209
-
1210
- var errors = e;
1211
-
1212
- if (!Array.isArray(errors)) {
1213
- errors = [errors];
1214
- }
1215
-
1216
- if (!options.suppressWarning && errors.length) {
1217
- Schema.warning('async-validator:', errors);
1218
- }
1219
-
1220
- if (errors.length && rule.message) {
1221
- errors = [].concat(rule.message);
1222
- }
1223
-
1224
- errors = errors.map(complementError(rule));
1225
-
1226
- if (options.first && errors.length) {
1227
- errorFields[rule.field] = 1;
1228
- return doIt(errors);
1229
- }
1230
-
1231
- if (!deep) {
1232
- doIt(errors);
1233
- } else {
1234
- // if rule is required but the target object
1235
- // does not exist fail at the rule level and don't
1236
- // go deeper
1237
- if (rule.required && !data.value) {
1238
- if (rule.message) {
1239
- errors = [].concat(rule.message).map(complementError(rule));
1240
- } else if (options.error) {
1241
- errors = [options.error(rule, format(options.messages.required, rule.field))];
1242
- } else {
1243
- errors = [];
1244
- }
1245
-
1246
- return doIt(errors);
1247
- }
1248
-
1249
- var fieldsSchema = {};
1250
-
1251
- if (rule.defaultField) {
1252
- for (var k in data.value) {
1253
- if (data.value.hasOwnProperty(k)) {
1254
- fieldsSchema[k] = rule.defaultField;
1255
- }
1256
- }
1257
- }
1258
-
1259
- fieldsSchema = _extends({}, fieldsSchema, {}, data.rule.fields);
1260
-
1261
- for (var f in fieldsSchema) {
1262
- if (fieldsSchema.hasOwnProperty(f)) {
1263
- var fieldSchema = Array.isArray(fieldsSchema[f]) ? fieldsSchema[f] : [fieldsSchema[f]];
1264
- fieldsSchema[f] = fieldSchema.map(addFullfield.bind(null, f));
1265
- }
1266
- }
1267
-
1268
- var schema = new Schema(fieldsSchema);
1269
- schema.messages(options.messages);
1270
-
1271
- if (data.rule.options) {
1272
- data.rule.options.messages = options.messages;
1273
- data.rule.options.error = options.error;
1274
- }
1275
-
1276
- schema.validate(data.value, data.rule.options || options, function (errs) {
1277
- var finalErrors = [];
1278
-
1279
- if (errors && errors.length) {
1280
- finalErrors.push.apply(finalErrors, errors);
1281
- }
1282
-
1283
- if (errs && errs.length) {
1284
- finalErrors.push.apply(finalErrors, errs);
1285
- }
1286
-
1287
- doIt(finalErrors.length ? finalErrors : null);
1288
- });
1289
- }
1290
- }
1291
-
1292
- var res;
1293
-
1294
- if (rule.asyncValidator) {
1295
- res = rule.asyncValidator(rule, data.value, cb, data.source, options);
1296
- } else if (rule.validator) {
1297
- res = rule.validator(rule, data.value, cb, data.source, options);
1298
-
1299
- if (res === true) {
1300
- cb();
1301
- } else if (res === false) {
1302
- cb(rule.message || rule.field + ' fails');
1303
- } else if (res instanceof Array) {
1304
- cb(res);
1305
- } else if (res instanceof Error) {
1306
- cb(res.message);
1307
- }
1308
- }
1309
-
1310
- if (res && res.then) {
1311
- res.then(
1312
- function () {
1313
- return cb();
1314
- },
1315
- function (e) {
1316
- return cb(e);
1317
- }
1318
- );
1319
- }
1320
- },
1321
- function (results) {
1322
- complete(results);
1323
- }
1324
- );
1325
- },
1326
- getType: function getType(rule) {
1327
- if (rule.type === undefined && rule.pattern instanceof RegExp) {
1328
- rule.type = 'pattern';
1329
- }
1330
-
1331
- if (typeof rule.validator !== 'function' && rule.type && !validators.hasOwnProperty(rule.type)) {
1332
- throw new Error(format('Unknown rule type %s', rule.type));
1333
- }
1334
-
1335
- return rule.type || 'string';
1336
- },
1337
- getValidationMethod: function getValidationMethod(rule) {
1338
- if (typeof rule.validator === 'function') {
1339
- return rule.validator;
1340
- }
1341
-
1342
- var keys = Object.keys(rule);
1343
- var messageIndex = keys.indexOf('message');
1344
-
1345
- if (messageIndex !== -1) {
1346
- keys.splice(messageIndex, 1);
1347
- }
1348
-
1349
- if (keys.length === 1 && keys[0] === 'required') {
1350
- return validators.required;
1351
- }
1352
-
1353
- return validators[this.getType(rule)] || false;
1354
- }
1355
- };
1356
-
1357
- Schema.register = function register(type, validator) {
1358
- if (typeof validator !== 'function') {
1359
- throw new Error('Cannot register a validator by type, validator is not a function');
1360
- }
1361
-
1362
- validators[type] = validator;
1363
- };
1364
-
1365
- Schema.warning = warning;
1366
- Schema.messages = messages;
1367
-
1368
- export default Schema;
1
+ // @ts-nocheck
2
+ function _extends() {
3
+ _extends =
4
+ Object.assign ||
5
+ function (target) {
6
+ for (var i = 1; i < arguments.length; i++) {
7
+ var source = arguments[i];
8
+
9
+ for (var key in source) {
10
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
11
+ target[key] = source[key];
12
+ }
13
+ }
14
+ }
15
+
16
+ return target;
17
+ };
18
+
19
+ return _extends.apply(this, arguments);
20
+ }
21
+
22
+ /* eslint no-console:0 */
23
+ var formatRegExp = /%[sdj%]/g;
24
+ var warning = function warning() {}; // don't print warning message when in production env or node runtime
25
+
26
+ if (typeof process !== 'undefined' && process.env && process.env.NODE_ENV !== 'production' && typeof window !== 'undefined' && typeof document !== 'undefined') {
27
+ warning = function warning(type, errors) {
28
+ if (typeof console !== 'undefined' && console.warn) {
29
+ if (
30
+ errors.every(function (e) {
31
+ return typeof e === 'string';
32
+ })
33
+ ) {
34
+ console.warn(type, errors);
35
+ }
36
+ }
37
+ };
38
+ }
39
+
40
+ function convertFieldsError(errors) {
41
+ if (!errors || !errors.length) return null;
42
+ var fields = {};
43
+ errors.forEach(function (error) {
44
+ var field = error.field;
45
+ fields[field] = fields[field] || [];
46
+ fields[field].push(error);
47
+ });
48
+ return fields;
49
+ }
50
+
51
+ function format() {
52
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
53
+ args[_key] = arguments[_key];
54
+ }
55
+
56
+ var i = 1;
57
+ var f = args[0];
58
+ var len = args.length;
59
+
60
+ if (typeof f === 'function') {
61
+ return f.apply(null, args.slice(1));
62
+ }
63
+
64
+ if (typeof f === 'string') {
65
+ var str = String(f).replace(formatRegExp, function (x) {
66
+ if (x === '%%') {
67
+ return '%';
68
+ }
69
+
70
+ if (i >= len) {
71
+ return x;
72
+ }
73
+
74
+ switch (x) {
75
+ case '%s':
76
+ return String(args[i++]);
77
+
78
+ case '%d':
79
+ return Number(args[i++]);
80
+
81
+ case '%j':
82
+ try {
83
+ return JSON.stringify(args[i++]);
84
+ } catch (_) {
85
+ return '[Circular]';
86
+ }
87
+
88
+ break;
89
+
90
+ default:
91
+ return x;
92
+ }
93
+ });
94
+
95
+ for (var arg = args[i]; i < len; arg = args[++i]) {
96
+ str += ' ' + arg;
97
+ }
98
+
99
+ return str;
100
+ }
101
+
102
+ return f;
103
+ }
104
+
105
+ function isNativeStringType(type) {
106
+ return type === 'string' || type === 'url' || type === 'hex' || type === 'email' || type === 'pattern';
107
+ }
108
+
109
+ function isEmptyValue(value, type) {
110
+ if (value === undefined || value === null) {
111
+ return true;
112
+ }
113
+
114
+ if (type === 'array' && Array.isArray(value) && !value.length) {
115
+ return true;
116
+ }
117
+
118
+ if (isNativeStringType(type) && typeof value === 'string' && !value) {
119
+ return true;
120
+ }
121
+
122
+ return false;
123
+ }
124
+
125
+ function asyncParallelArray(arr, func, callback) {
126
+ var results = [];
127
+ var total = 0;
128
+ var arrLength = arr.length;
129
+
130
+ function count(errors) {
131
+ results.push.apply(results, errors);
132
+ total++;
133
+
134
+ if (total === arrLength) {
135
+ callback(results);
136
+ }
137
+ }
138
+
139
+ arr.forEach(function (a) {
140
+ func(a, count);
141
+ });
142
+ }
143
+
144
+ function asyncSerialArray(arr, func, callback) {
145
+ var index = 0;
146
+ var arrLength = arr.length;
147
+
148
+ function next(errors) {
149
+ if (errors && errors.length) {
150
+ callback(errors);
151
+ return;
152
+ }
153
+
154
+ var original = index;
155
+ index = index + 1;
156
+
157
+ if (original < arrLength) {
158
+ func(arr[original], next);
159
+ } else {
160
+ callback([]);
161
+ }
162
+ }
163
+
164
+ next([]);
165
+ }
166
+
167
+ function flattenObjArr(objArr) {
168
+ var ret = [];
169
+ Object.keys(objArr).forEach(function (k) {
170
+ ret.push.apply(ret, objArr[k]);
171
+ });
172
+ return ret;
173
+ }
174
+
175
+ function asyncMap(objArr, option, func, callback) {
176
+ if (option.first) {
177
+ var _pending = new Promise(function (resolve, reject) {
178
+ var next = function next(errors) {
179
+ callback(errors);
180
+ return errors.length
181
+ ? reject({
182
+ errors: errors,
183
+ fields: convertFieldsError(errors)
184
+ })
185
+ : resolve();
186
+ };
187
+
188
+ var flattenArr = flattenObjArr(objArr);
189
+ asyncSerialArray(flattenArr, func, next);
190
+ });
191
+
192
+ _pending['catch'](function (e) {
193
+ return e;
194
+ });
195
+
196
+ return _pending;
197
+ }
198
+
199
+ var firstFields = option.firstFields || [];
200
+
201
+ if (firstFields === true) {
202
+ firstFields = Object.keys(objArr);
203
+ }
204
+
205
+ var objArrKeys = Object.keys(objArr);
206
+ var objArrLength = objArrKeys.length;
207
+ var total = 0;
208
+ var results = [];
209
+ var pending = new Promise(function (resolve, reject) {
210
+ var next = function next(errors) {
211
+ results.push.apply(results, errors);
212
+ total++;
213
+
214
+ if (total === objArrLength) {
215
+ callback(results);
216
+ return results.length
217
+ ? reject({
218
+ errors: results,
219
+ fields: convertFieldsError(results)
220
+ })
221
+ : resolve();
222
+ }
223
+ };
224
+
225
+ if (!objArrKeys.length) {
226
+ callback(results);
227
+ resolve();
228
+ }
229
+
230
+ objArrKeys.forEach(function (key) {
231
+ var arr = objArr[key];
232
+
233
+ if (firstFields.indexOf(key) !== -1) {
234
+ asyncSerialArray(arr, func, next);
235
+ } else {
236
+ asyncParallelArray(arr, func, next);
237
+ }
238
+ });
239
+ });
240
+ pending['catch'](function (e) {
241
+ return e;
242
+ });
243
+ return pending;
244
+ }
245
+
246
+ function complementError(rule) {
247
+ return function (oe) {
248
+ if (oe && oe.message) {
249
+ oe.field = oe.field || rule.fullField;
250
+ return oe;
251
+ }
252
+
253
+ return {
254
+ message: typeof oe === 'function' ? oe() : oe,
255
+ field: oe.field || rule.fullField
256
+ };
257
+ };
258
+ }
259
+
260
+ function deepMerge(target, source) {
261
+ if (source) {
262
+ for (var s in source) {
263
+ if (source.hasOwnProperty(s)) {
264
+ var value = source[s];
265
+
266
+ if (typeof value === 'object' && typeof target[s] === 'object') {
267
+ target[s] = _extends({}, target[s], {}, value);
268
+ } else {
269
+ target[s] = value;
270
+ }
271
+ }
272
+ }
273
+ }
274
+
275
+ return target;
276
+ }
277
+
278
+ /**
279
+ * Rule for validating required fields.
280
+ *
281
+ * @param rule The validation rule.
282
+ * @param value The value of the field on the source object.
283
+ * @param source The source object being validated.
284
+ * @param errors An array of errors that this rule may add
285
+ * validation errors to.
286
+ * @param options The validation options.
287
+ * @param options.messages The validation messages.
288
+ */
289
+
290
+ function required(rule, value, source, errors, options, type) {
291
+ if (rule.required && (!source.hasOwnProperty(rule.field) || isEmptyValue(value, type || rule.type))) {
292
+ errors.push(format(options.messages.required, rule.fullField));
293
+ }
294
+ }
295
+
296
+ /**
297
+ * Rule for validating whitespace.
298
+ *
299
+ * @param rule The validation rule.
300
+ * @param value The value of the field on the source object.
301
+ * @param source The source object being validated.
302
+ * @param errors An array of errors that this rule may add
303
+ * validation errors to.
304
+ * @param options The validation options.
305
+ * @param options.messages The validation messages.
306
+ */
307
+
308
+ function whitespace(rule, value, source, errors, options) {
309
+ if (/^\s+$/.test(value) || value === '') {
310
+ errors.push(format(options.messages.whitespace, rule.fullField));
311
+ }
312
+ }
313
+
314
+ /* eslint max-len:0 */
315
+
316
+ var pattern = {
317
+ // http://emailregex.com/
318
+ 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,}))$/,
319
+ url: new RegExp(
320
+ '^(?!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]*)?$',
321
+ 'i'
322
+ ),
323
+ hex: /^#?([a-f0-9]{6}|[a-f0-9]{3})$/i
324
+ };
325
+ var types = {
326
+ integer: function integer(value) {
327
+ return types.number(value) && parseInt(value, 10) === value;
328
+ },
329
+ float: function float(value) {
330
+ return types.number(value) && !types.integer(value);
331
+ },
332
+ array: function array(value) {
333
+ return Array.isArray(value);
334
+ },
335
+ regexp: function regexp(value) {
336
+ if (value instanceof RegExp) {
337
+ return true;
338
+ }
339
+
340
+ try {
341
+ return !!new RegExp(value);
342
+ } catch (e) {
343
+ return false;
344
+ }
345
+ },
346
+ date: function date(value) {
347
+ return typeof value.getTime === 'function' && typeof value.getMonth === 'function' && typeof value.getYear === 'function';
348
+ },
349
+ number: function number(value) {
350
+ if (isNaN(value)) {
351
+ return false;
352
+ }
353
+
354
+ // 修改源码,将字符串数值先转为数值
355
+ return typeof +value === 'number';
356
+ },
357
+ object: function object(value) {
358
+ return typeof value === 'object' && !types.array(value);
359
+ },
360
+ method: function method(value) {
361
+ return typeof value === 'function';
362
+ },
363
+ email: function email(value) {
364
+ return typeof value === 'string' && !!value.match(pattern.email) && value.length < 255;
365
+ },
366
+ url: function url(value) {
367
+ return typeof value === 'string' && !!value.match(pattern.url);
368
+ },
369
+ hex: function hex(value) {
370
+ return typeof value === 'string' && !!value.match(pattern.hex);
371
+ }
372
+ };
373
+ /**
374
+ * Rule for validating the type of a value.
375
+ *
376
+ * @param rule The validation rule.
377
+ * @param value The value of the field on the source object.
378
+ * @param source The source object being validated.
379
+ * @param errors An array of errors that this rule may add
380
+ * validation errors to.
381
+ * @param options The validation options.
382
+ * @param options.messages The validation messages.
383
+ */
384
+
385
+ function type(rule, value, source, errors, options) {
386
+ if (rule.required && value === undefined) {
387
+ required(rule, value, source, errors, options);
388
+ return;
389
+ }
390
+
391
+ var custom = ['integer', 'float', 'array', 'regexp', 'object', 'method', 'email', 'number', 'date', 'url', 'hex'];
392
+ var ruleType = rule.type;
393
+
394
+ if (custom.indexOf(ruleType) > -1) {
395
+ if (!types[ruleType](value)) {
396
+ errors.push(format(options.messages.types[ruleType], rule.fullField, rule.type));
397
+ } // straight typeof check
398
+ } else if (ruleType && typeof value !== rule.type) {
399
+ errors.push(format(options.messages.types[ruleType], rule.fullField, rule.type));
400
+ }
401
+ }
402
+
403
+ /**
404
+ * Rule for validating minimum and maximum allowed values.
405
+ *
406
+ * @param rule The validation rule.
407
+ * @param value The value of the field on the source object.
408
+ * @param source The source object being validated.
409
+ * @param errors An array of errors that this rule may add
410
+ * validation errors to.
411
+ * @param options The validation options.
412
+ * @param options.messages The validation messages.
413
+ */
414
+
415
+ function range(rule, value, source, errors, options) {
416
+ var len = typeof rule.len === 'number';
417
+ var min = typeof rule.min === 'number';
418
+ var max = typeof rule.max === 'number'; // 正则匹配码点范围从U+010000一直到U+10FFFF的文字(补充平面Supplementary Plane)
419
+
420
+ var spRegexp = /[\uD800-\uDBFF][\uDC00-\uDFFF]/g;
421
+ var val = value;
422
+ var key = null;
423
+ var num = typeof value === 'number';
424
+ var str = typeof value === 'string';
425
+ var arr = Array.isArray(value);
426
+
427
+ if (num) {
428
+ key = 'number';
429
+ } else if (str) {
430
+ key = 'string';
431
+ } else if (arr) {
432
+ key = 'array';
433
+ } // if the value is not of a supported type for range validation
434
+ // the validation rule rule should use the
435
+ // type property to also test for a particular type
436
+
437
+ if (!key) {
438
+ return false;
439
+ }
440
+
441
+ if (arr) {
442
+ val = value.length;
443
+ }
444
+
445
+ if (str) {
446
+ // 处理码点大于U+010000的文字length属性不准确的bug,如"𠮷𠮷𠮷".length !== 3
447
+ val = value.replace(spRegexp, '_').length;
448
+ }
449
+
450
+ if (len) {
451
+ if (val !== rule.len) {
452
+ errors.push(format(options.messages[key].len, rule.fullField, rule.len));
453
+ }
454
+ } else if (min && !max && val < rule.min) {
455
+ errors.push(format(options.messages[key].min, rule.fullField, rule.min));
456
+ } else if (max && !min && val > rule.max) {
457
+ errors.push(format(options.messages[key].max, rule.fullField, rule.max));
458
+ } else if (min && max && (val < rule.min || val > rule.max)) {
459
+ errors.push(format(options.messages[key].range, rule.fullField, rule.min, rule.max));
460
+ }
461
+ }
462
+
463
+ var ENUM = 'enum';
464
+ /**
465
+ * Rule for validating a value exists in an enumerable list.
466
+ *
467
+ * @param rule The validation rule.
468
+ * @param value The value of the field on the source object.
469
+ * @param source The source object being validated.
470
+ * @param errors An array of errors that this rule may add
471
+ * validation errors to.
472
+ * @param options The validation options.
473
+ * @param options.messages The validation messages.
474
+ */
475
+
476
+ function enumerable(rule, value, source, errors, options) {
477
+ rule[ENUM] = Array.isArray(rule[ENUM]) ? rule[ENUM] : [];
478
+
479
+ if (rule[ENUM].indexOf(value) === -1) {
480
+ errors.push(format(options.messages[ENUM], rule.fullField, rule[ENUM].join(', ')));
481
+ }
482
+ }
483
+
484
+ /**
485
+ * Rule for validating a regular expression pattern.
486
+ *
487
+ * @param rule The validation rule.
488
+ * @param value The value of the field on the source object.
489
+ * @param source The source object being validated.
490
+ * @param errors An array of errors that this rule may add
491
+ * validation errors to.
492
+ * @param options The validation options.
493
+ * @param options.messages The validation messages.
494
+ */
495
+
496
+ function pattern$1(rule, value, source, errors, options) {
497
+ if (rule.pattern) {
498
+ if (rule.pattern instanceof RegExp) {
499
+ // if a RegExp instance is passed, reset `lastIndex` in case its `global`
500
+ // flag is accidentally set to `true`, which in a validation scenario
501
+ // is not necessary and the result might be misleading
502
+ rule.pattern.lastIndex = 0;
503
+
504
+ if (!rule.pattern.test(value)) {
505
+ errors.push(format(options.messages.pattern.mismatch, rule.fullField, value, rule.pattern));
506
+ }
507
+ } else if (typeof rule.pattern === 'string') {
508
+ var _pattern = new RegExp(rule.pattern);
509
+
510
+ if (!_pattern.test(value)) {
511
+ errors.push(format(options.messages.pattern.mismatch, rule.fullField, value, rule.pattern));
512
+ }
513
+ }
514
+ }
515
+ }
516
+
517
+ var rules = {
518
+ required: required,
519
+ whitespace: whitespace,
520
+ type: type,
521
+ range: range,
522
+ enum: enumerable,
523
+ pattern: pattern$1
524
+ };
525
+
526
+ /**
527
+ * Performs validation for string types.
528
+ *
529
+ * @param rule The validation rule.
530
+ * @param value The value of the field on the source object.
531
+ * @param callback The callback function.
532
+ * @param source The source object being validated.
533
+ * @param options The validation options.
534
+ * @param options.messages The validation messages.
535
+ */
536
+
537
+ function string(rule, value, callback, source, options) {
538
+ var errors = [];
539
+ var validate = rule.required || (!rule.required && source.hasOwnProperty(rule.field));
540
+
541
+ if (validate) {
542
+ if (isEmptyValue(value, 'string') && !rule.required) {
543
+ return callback();
544
+ }
545
+
546
+ rules.required(rule, value, source, errors, options, 'string');
547
+
548
+ if (!isEmptyValue(value, 'string')) {
549
+ rules.type(rule, value, source, errors, options);
550
+ rules.range(rule, value, source, errors, options);
551
+ rules.pattern(rule, value, source, errors, options);
552
+
553
+ if (rule.whitespace === true) {
554
+ rules.whitespace(rule, value, source, errors, options);
555
+ }
556
+ }
557
+ }
558
+
559
+ callback(errors);
560
+ }
561
+
562
+ /**
563
+ * Validates a function.
564
+ *
565
+ * @param rule The validation rule.
566
+ * @param value The value of the field on the source object.
567
+ * @param callback The callback function.
568
+ * @param source The source object being validated.
569
+ * @param options The validation options.
570
+ * @param options.messages The validation messages.
571
+ */
572
+
573
+ function method(rule, value, callback, source, options) {
574
+ var errors = [];
575
+ var validate = rule.required || (!rule.required && source.hasOwnProperty(rule.field));
576
+
577
+ if (validate) {
578
+ if (isEmptyValue(value) && !rule.required) {
579
+ return callback();
580
+ }
581
+
582
+ rules.required(rule, value, source, errors, options);
583
+
584
+ if (value !== undefined) {
585
+ rules.type(rule, value, source, errors, options);
586
+ }
587
+ }
588
+
589
+ callback(errors);
590
+ }
591
+
592
+ /**
593
+ * Validates a number.
594
+ *
595
+ * @param rule The validation rule.
596
+ * @param value The value of the field on the source object.
597
+ * @param callback The callback function.
598
+ * @param source The source object being validated.
599
+ * @param options The validation options.
600
+ * @param options.messages The validation messages.
601
+ */
602
+
603
+ function number(rule, value, callback, source, options) {
604
+ var errors = [];
605
+ var validate = rule.required || (!rule.required && source.hasOwnProperty(rule.field));
606
+
607
+ if (validate) {
608
+ if (value === '') {
609
+ value = undefined;
610
+ }
611
+
612
+ if (isEmptyValue(value) && !rule.required) {
613
+ return callback();
614
+ }
615
+
616
+ rules.required(rule, value, source, errors, options);
617
+
618
+ if (value !== undefined) {
619
+ rules.type(rule, value, source, errors, options);
620
+ rules.range(rule, value, source, errors, options);
621
+ }
622
+ }
623
+
624
+ callback(errors);
625
+ }
626
+
627
+ /**
628
+ * Validates a boolean.
629
+ *
630
+ * @param rule The validation rule.
631
+ * @param value The value of the field on the source object.
632
+ * @param callback The callback function.
633
+ * @param source The source object being validated.
634
+ * @param options The validation options.
635
+ * @param options.messages The validation messages.
636
+ */
637
+
638
+ function _boolean(rule, value, callback, source, options) {
639
+ var errors = [];
640
+ var validate = rule.required || (!rule.required && source.hasOwnProperty(rule.field));
641
+
642
+ if (validate) {
643
+ if (isEmptyValue(value) && !rule.required) {
644
+ return callback();
645
+ }
646
+
647
+ rules.required(rule, value, source, errors, options);
648
+
649
+ if (value !== undefined) {
650
+ rules.type(rule, value, source, errors, options);
651
+ }
652
+ }
653
+
654
+ callback(errors);
655
+ }
656
+
657
+ /**
658
+ * Validates the regular expression type.
659
+ *
660
+ * @param rule The validation rule.
661
+ * @param value The value of the field on the source object.
662
+ * @param callback The callback function.
663
+ * @param source The source object being validated.
664
+ * @param options The validation options.
665
+ * @param options.messages The validation messages.
666
+ */
667
+
668
+ function regexp(rule, value, callback, source, options) {
669
+ var errors = [];
670
+ var validate = rule.required || (!rule.required && source.hasOwnProperty(rule.field));
671
+
672
+ if (validate) {
673
+ if (isEmptyValue(value) && !rule.required) {
674
+ return callback();
675
+ }
676
+
677
+ rules.required(rule, value, source, errors, options);
678
+
679
+ if (!isEmptyValue(value)) {
680
+ rules.type(rule, value, source, errors, options);
681
+ }
682
+ }
683
+
684
+ callback(errors);
685
+ }
686
+
687
+ /**
688
+ * Validates a number is an integer.
689
+ *
690
+ * @param rule The validation rule.
691
+ * @param value The value of the field on the source object.
692
+ * @param callback The callback function.
693
+ * @param source The source object being validated.
694
+ * @param options The validation options.
695
+ * @param options.messages The validation messages.
696
+ */
697
+
698
+ function integer(rule, value, callback, source, options) {
699
+ var errors = [];
700
+ var validate = rule.required || (!rule.required && source.hasOwnProperty(rule.field));
701
+
702
+ if (validate) {
703
+ if (isEmptyValue(value) && !rule.required) {
704
+ return callback();
705
+ }
706
+
707
+ rules.required(rule, value, source, errors, options);
708
+
709
+ if (value !== undefined) {
710
+ rules.type(rule, value, source, errors, options);
711
+ rules.range(rule, value, source, errors, options);
712
+ }
713
+ }
714
+
715
+ callback(errors);
716
+ }
717
+
718
+ /**
719
+ * Validates a number is a floating point number.
720
+ *
721
+ * @param rule The validation rule.
722
+ * @param value The value of the field on the source object.
723
+ * @param callback The callback function.
724
+ * @param source The source object being validated.
725
+ * @param options The validation options.
726
+ * @param options.messages The validation messages.
727
+ */
728
+
729
+ function floatFn(rule, value, callback, source, options) {
730
+ var errors = [];
731
+ var validate = rule.required || (!rule.required && source.hasOwnProperty(rule.field));
732
+
733
+ if (validate) {
734
+ if (isEmptyValue(value) && !rule.required) {
735
+ return callback();
736
+ }
737
+
738
+ rules.required(rule, value, source, errors, options);
739
+
740
+ if (value !== undefined) {
741
+ rules.type(rule, value, source, errors, options);
742
+ rules.range(rule, value, source, errors, options);
743
+ }
744
+ }
745
+
746
+ callback(errors);
747
+ }
748
+
749
+ /**
750
+ * Validates an array.
751
+ *
752
+ * @param rule The validation rule.
753
+ * @param value The value of the field on the source object.
754
+ * @param callback The callback function.
755
+ * @param source The source object being validated.
756
+ * @param options The validation options.
757
+ * @param options.messages The validation messages.
758
+ */
759
+
760
+ function array(rule, value, callback, source, options) {
761
+ var errors = [];
762
+ var validate = rule.required || (!rule.required && source.hasOwnProperty(rule.field));
763
+
764
+ if (validate) {
765
+ if (isEmptyValue(value, 'array') && !rule.required) {
766
+ return callback();
767
+ }
768
+
769
+ rules.required(rule, value, source, errors, options, 'array');
770
+
771
+ if (!isEmptyValue(value, 'array')) {
772
+ rules.type(rule, value, source, errors, options);
773
+ rules.range(rule, value, source, errors, options);
774
+ }
775
+ }
776
+
777
+ callback(errors);
778
+ }
779
+
780
+ /**
781
+ * Validates an object.
782
+ *
783
+ * @param rule The validation rule.
784
+ * @param value The value of the field on the source object.
785
+ * @param callback The callback function.
786
+ * @param source The source object being validated.
787
+ * @param options The validation options.
788
+ * @param options.messages The validation messages.
789
+ */
790
+
791
+ function object(rule, value, callback, source, options) {
792
+ var errors = [];
793
+ var validate = rule.required || (!rule.required && source.hasOwnProperty(rule.field));
794
+
795
+ if (validate) {
796
+ if (isEmptyValue(value) && !rule.required) {
797
+ return callback();
798
+ }
799
+
800
+ rules.required(rule, value, source, errors, options);
801
+
802
+ if (value !== undefined) {
803
+ rules.type(rule, value, source, errors, options);
804
+ }
805
+ }
806
+
807
+ callback(errors);
808
+ }
809
+
810
+ var ENUM$1 = 'enum';
811
+ /**
812
+ * Validates an enumerable list.
813
+ *
814
+ * @param rule The validation rule.
815
+ * @param value The value of the field on the source object.
816
+ * @param callback The callback function.
817
+ * @param source The source object being validated.
818
+ * @param options The validation options.
819
+ * @param options.messages The validation messages.
820
+ */
821
+
822
+ function enumerable$1(rule, value, callback, source, options) {
823
+ var errors = [];
824
+ var validate = rule.required || (!rule.required && source.hasOwnProperty(rule.field));
825
+
826
+ if (validate) {
827
+ if (isEmptyValue(value) && !rule.required) {
828
+ return callback();
829
+ }
830
+
831
+ rules.required(rule, value, source, errors, options);
832
+
833
+ if (value !== undefined) {
834
+ rules[ENUM$1](rule, value, source, errors, options);
835
+ }
836
+ }
837
+
838
+ callback(errors);
839
+ }
840
+
841
+ /**
842
+ * Validates a regular expression pattern.
843
+ *
844
+ * Performs validation when a rule only contains
845
+ * a pattern property but is not declared as a string type.
846
+ *
847
+ * @param rule The validation rule.
848
+ * @param value The value of the field on the source object.
849
+ * @param callback The callback function.
850
+ * @param source The source object being validated.
851
+ * @param options The validation options.
852
+ * @param options.messages The validation messages.
853
+ */
854
+
855
+ function pattern$2(rule, value, callback, source, options) {
856
+ var errors = [];
857
+ var validate = rule.required || (!rule.required && source.hasOwnProperty(rule.field));
858
+
859
+ if (validate) {
860
+ if (isEmptyValue(value, 'string') && !rule.required) {
861
+ return callback();
862
+ }
863
+
864
+ rules.required(rule, value, source, errors, options);
865
+
866
+ if (!isEmptyValue(value, 'string')) {
867
+ rules.pattern(rule, value, source, errors, options);
868
+ }
869
+ }
870
+
871
+ callback(errors);
872
+ }
873
+
874
+ function date(rule, value, callback, source, options) {
875
+ var errors = [];
876
+ var validate = rule.required || (!rule.required && source.hasOwnProperty(rule.field));
877
+
878
+ if (validate) {
879
+ if (isEmptyValue(value) && !rule.required) {
880
+ return callback();
881
+ }
882
+
883
+ rules.required(rule, value, source, errors, options);
884
+
885
+ if (!isEmptyValue(value)) {
886
+ var dateObject;
887
+
888
+ if (typeof value === 'number') {
889
+ dateObject = new Date(value);
890
+ } else {
891
+ dateObject = value;
892
+ }
893
+
894
+ rules.type(rule, dateObject, source, errors, options);
895
+
896
+ if (dateObject) {
897
+ rules.range(rule, dateObject.getTime(), source, errors, options);
898
+ }
899
+ }
900
+ }
901
+
902
+ callback(errors);
903
+ }
904
+
905
+ function required$1(rule, value, callback, source, options) {
906
+ var errors = [];
907
+ var type = Array.isArray(value) ? 'array' : typeof value;
908
+ rules.required(rule, value, source, errors, options, type);
909
+ callback(errors);
910
+ }
911
+
912
+ function type$1(rule, value, callback, source, options) {
913
+ var ruleType = rule.type;
914
+ var errors = [];
915
+ var validate = rule.required || (!rule.required && source.hasOwnProperty(rule.field));
916
+
917
+ if (validate) {
918
+ if (isEmptyValue(value, ruleType) && !rule.required) {
919
+ return callback();
920
+ }
921
+
922
+ rules.required(rule, value, source, errors, options, ruleType);
923
+
924
+ if (!isEmptyValue(value, ruleType)) {
925
+ rules.type(rule, value, source, errors, options);
926
+ }
927
+ }
928
+
929
+ callback(errors);
930
+ }
931
+
932
+ /**
933
+ * Performs validation for any type.
934
+ *
935
+ * @param rule The validation rule.
936
+ * @param value The value of the field on the source object.
937
+ * @param callback The callback function.
938
+ * @param source The source object being validated.
939
+ * @param options The validation options.
940
+ * @param options.messages The validation messages.
941
+ */
942
+
943
+ function any(rule, value, callback, source, options) {
944
+ var errors = [];
945
+ var validate = rule.required || (!rule.required && source.hasOwnProperty(rule.field));
946
+
947
+ if (validate) {
948
+ if (isEmptyValue(value) && !rule.required) {
949
+ return callback();
950
+ }
951
+
952
+ rules.required(rule, value, source, errors, options);
953
+ }
954
+
955
+ callback(errors);
956
+ }
957
+
958
+ var validators = {
959
+ string: string,
960
+ method: method,
961
+ number: number,
962
+ boolean: _boolean,
963
+ regexp: regexp,
964
+ integer: integer,
965
+ float: floatFn,
966
+ array: array,
967
+ object: object,
968
+ enum: enumerable$1,
969
+ pattern: pattern$2,
970
+ date: date,
971
+ url: type$1,
972
+ hex: type$1,
973
+ email: type$1,
974
+ required: required$1,
975
+ any: any
976
+ };
977
+
978
+ function newMessages() {
979
+ return {
980
+ default: 'Validation error on field %s',
981
+ required: '%s is required',
982
+ enum: '%s must be one of %s',
983
+ whitespace: '%s cannot be empty',
984
+ date: {
985
+ format: '%s date %s is invalid for format %s',
986
+ parse: '%s date could not be parsed, %s is invalid ',
987
+ invalid: '%s date %s is invalid'
988
+ },
989
+ types: {
990
+ string: '%s is not a %s',
991
+ method: '%s is not a %s (function)',
992
+ array: '%s is not an %s',
993
+ object: '%s is not an %s',
994
+ number: '%s is not a %s',
995
+ date: '%s is not a %s',
996
+ boolean: '%s is not a %s',
997
+ integer: '%s is not an %s',
998
+ float: '%s is not a %s',
999
+ regexp: '%s is not a valid %s',
1000
+ email: '%s is not a valid %s',
1001
+ url: '%s is not a valid %s',
1002
+ hex: '%s is not a valid %s'
1003
+ },
1004
+ string: {
1005
+ len: '%s must be exactly %s characters',
1006
+ min: '%s must be at least %s characters',
1007
+ max: '%s cannot be longer than %s characters',
1008
+ range: '%s must be between %s and %s characters'
1009
+ },
1010
+ number: {
1011
+ len: '%s must equal %s',
1012
+ min: '%s cannot be less than %s',
1013
+ max: '%s cannot be greater than %s',
1014
+ range: '%s must be between %s and %s'
1015
+ },
1016
+ array: {
1017
+ len: '%s must be exactly %s in length',
1018
+ min: '%s cannot be less than %s in length',
1019
+ max: '%s cannot be greater than %s in length',
1020
+ range: '%s must be between %s and %s in length'
1021
+ },
1022
+ pattern: {
1023
+ mismatch: '%s value %s does not match pattern %s'
1024
+ },
1025
+ clone: function clone() {
1026
+ var cloned = JSON.parse(JSON.stringify(this));
1027
+ cloned.clone = this.clone;
1028
+ return cloned;
1029
+ }
1030
+ };
1031
+ }
1032
+ var messages = newMessages();
1033
+
1034
+ /**
1035
+ * Encapsulates a validation schema.
1036
+ *
1037
+ * @param descriptor An object declaring validation rules
1038
+ * for this schema.
1039
+ */
1040
+
1041
+ function Schema(descriptor) {
1042
+ this.rules = null;
1043
+ this._messages = messages;
1044
+ this.define(descriptor);
1045
+ }
1046
+
1047
+ Schema.prototype = {
1048
+ messages: function messages(_messages) {
1049
+ if (_messages) {
1050
+ this._messages = deepMerge(newMessages(), _messages);
1051
+ }
1052
+
1053
+ return this._messages;
1054
+ },
1055
+ define: function define(rules) {
1056
+ if (!rules) {
1057
+ throw new Error('Cannot configure a schema with no rules');
1058
+ }
1059
+
1060
+ if (typeof rules !== 'object' || Array.isArray(rules)) {
1061
+ throw new Error('Rules must be an object');
1062
+ }
1063
+
1064
+ this.rules = {};
1065
+ var z;
1066
+ var item;
1067
+
1068
+ for (z in rules) {
1069
+ if (rules.hasOwnProperty(z)) {
1070
+ item = rules[z];
1071
+ this.rules[z] = Array.isArray(item) ? item : [item];
1072
+ }
1073
+ }
1074
+ },
1075
+ validate: function validate(source_, o, oc) {
1076
+ var _this = this;
1077
+
1078
+ if (o === void 0) {
1079
+ o = {};
1080
+ }
1081
+
1082
+ if (oc === void 0) {
1083
+ oc = function oc() {};
1084
+ }
1085
+
1086
+ var source = source_;
1087
+ var options = o;
1088
+ var callback = oc;
1089
+
1090
+ if (typeof options === 'function') {
1091
+ callback = options;
1092
+ options = {};
1093
+ }
1094
+
1095
+ if (!this.rules || Object.keys(this.rules).length === 0) {
1096
+ if (callback) {
1097
+ callback();
1098
+ }
1099
+
1100
+ return Promise.resolve();
1101
+ }
1102
+
1103
+ function complete(results) {
1104
+ var i;
1105
+ var errors = [];
1106
+ var fields = {};
1107
+
1108
+ function add(e) {
1109
+ if (Array.isArray(e)) {
1110
+ var _errors;
1111
+
1112
+ errors = (_errors = errors).concat.apply(_errors, e);
1113
+ } else {
1114
+ errors.push(e);
1115
+ }
1116
+ }
1117
+
1118
+ for (i = 0; i < results.length; i++) {
1119
+ add(results[i]);
1120
+ }
1121
+
1122
+ if (!errors.length) {
1123
+ errors = null;
1124
+ fields = null;
1125
+ } else {
1126
+ fields = convertFieldsError(errors);
1127
+ }
1128
+
1129
+ callback(errors, fields);
1130
+ }
1131
+
1132
+ if (options.messages) {
1133
+ var messages$1 = this.messages();
1134
+
1135
+ if (messages$1 === messages) {
1136
+ messages$1 = newMessages();
1137
+ }
1138
+
1139
+ deepMerge(messages$1, options.messages);
1140
+ options.messages = messages$1;
1141
+ } else {
1142
+ options.messages = this.messages();
1143
+ }
1144
+
1145
+ var arr;
1146
+ var value;
1147
+ var series = {};
1148
+ var keys = options.keys || Object.keys(this.rules);
1149
+ keys.forEach(function (z) {
1150
+ arr = _this.rules[z];
1151
+ value = source[z];
1152
+ arr.forEach(function (r) {
1153
+ var rule = r;
1154
+
1155
+ if (typeof rule.transform === 'function') {
1156
+ if (source === source_) {
1157
+ source = _extends({}, source);
1158
+ }
1159
+
1160
+ value = source[z] = rule.transform(value);
1161
+ }
1162
+
1163
+ if (typeof rule === 'function') {
1164
+ rule = {
1165
+ validator: rule
1166
+ };
1167
+ } else {
1168
+ rule = _extends({}, rule);
1169
+ }
1170
+
1171
+ rule.validator = _this.getValidationMethod(rule);
1172
+ rule.field = z;
1173
+ rule.fullField = rule.fullField || z;
1174
+ rule.type = _this.getType(rule);
1175
+
1176
+ if (!rule.validator) {
1177
+ return;
1178
+ }
1179
+
1180
+ series[z] = series[z] || [];
1181
+ series[z].push({
1182
+ rule: rule,
1183
+ value: value,
1184
+ source: source,
1185
+ field: z
1186
+ });
1187
+ });
1188
+ });
1189
+ var errorFields = {};
1190
+ return asyncMap(
1191
+ series,
1192
+ options,
1193
+ function (data, doIt) {
1194
+ var rule = data.rule;
1195
+ var deep = (rule.type === 'object' || rule.type === 'array') && (typeof rule.fields === 'object' || typeof rule.defaultField === 'object');
1196
+ deep = deep && (rule.required || (!rule.required && data.value));
1197
+ rule.field = data.field;
1198
+
1199
+ function addFullfield(key, schema) {
1200
+ return _extends({}, schema, {
1201
+ fullField: rule.fullField + '.' + key
1202
+ });
1203
+ }
1204
+
1205
+ function cb(e) {
1206
+ if (e === void 0) {
1207
+ e = [];
1208
+ }
1209
+
1210
+ var errors = e;
1211
+
1212
+ if (!Array.isArray(errors)) {
1213
+ errors = [errors];
1214
+ }
1215
+
1216
+ if (!options.suppressWarning && errors.length) {
1217
+ Schema.warning('async-validator:', errors);
1218
+ }
1219
+
1220
+ if (errors.length && rule.message) {
1221
+ errors = [].concat(rule.message);
1222
+ }
1223
+
1224
+ errors = errors.map(complementError(rule));
1225
+
1226
+ if (options.first && errors.length) {
1227
+ errorFields[rule.field] = 1;
1228
+ return doIt(errors);
1229
+ }
1230
+
1231
+ if (!deep) {
1232
+ doIt(errors);
1233
+ } else {
1234
+ // if rule is required but the target object
1235
+ // does not exist fail at the rule level and don't
1236
+ // go deeper
1237
+ if (rule.required && !data.value) {
1238
+ if (rule.message) {
1239
+ errors = [].concat(rule.message).map(complementError(rule));
1240
+ } else if (options.error) {
1241
+ errors = [options.error(rule, format(options.messages.required, rule.field))];
1242
+ } else {
1243
+ errors = [];
1244
+ }
1245
+
1246
+ return doIt(errors);
1247
+ }
1248
+
1249
+ var fieldsSchema = {};
1250
+
1251
+ if (rule.defaultField) {
1252
+ for (var k in data.value) {
1253
+ if (data.value.hasOwnProperty(k)) {
1254
+ fieldsSchema[k] = rule.defaultField;
1255
+ }
1256
+ }
1257
+ }
1258
+
1259
+ fieldsSchema = _extends({}, fieldsSchema, {}, data.rule.fields);
1260
+
1261
+ for (var f in fieldsSchema) {
1262
+ if (fieldsSchema.hasOwnProperty(f)) {
1263
+ var fieldSchema = Array.isArray(fieldsSchema[f]) ? fieldsSchema[f] : [fieldsSchema[f]];
1264
+ fieldsSchema[f] = fieldSchema.map(addFullfield.bind(null, f));
1265
+ }
1266
+ }
1267
+
1268
+ var schema = new Schema(fieldsSchema);
1269
+ schema.messages(options.messages);
1270
+
1271
+ if (data.rule.options) {
1272
+ data.rule.options.messages = options.messages;
1273
+ data.rule.options.error = options.error;
1274
+ }
1275
+
1276
+ schema.validate(data.value, data.rule.options || options, function (errs) {
1277
+ var finalErrors = [];
1278
+
1279
+ if (errors && errors.length) {
1280
+ finalErrors.push.apply(finalErrors, errors);
1281
+ }
1282
+
1283
+ if (errs && errs.length) {
1284
+ finalErrors.push.apply(finalErrors, errs);
1285
+ }
1286
+
1287
+ doIt(finalErrors.length ? finalErrors : null);
1288
+ });
1289
+ }
1290
+ }
1291
+
1292
+ var res;
1293
+
1294
+ if (rule.asyncValidator) {
1295
+ res = rule.asyncValidator(rule, data.value, cb, data.source, options);
1296
+ } else if (rule.validator) {
1297
+ res = rule.validator(rule, data.value, cb, data.source, options);
1298
+
1299
+ if (res === true) {
1300
+ cb();
1301
+ } else if (res === false) {
1302
+ cb(rule.message || rule.field + ' fails');
1303
+ } else if (res instanceof Array) {
1304
+ cb(res);
1305
+ } else if (res instanceof Error) {
1306
+ cb(res.message);
1307
+ }
1308
+ }
1309
+
1310
+ if (res && res.then) {
1311
+ res.then(
1312
+ function () {
1313
+ return cb();
1314
+ },
1315
+ function (e) {
1316
+ return cb(e);
1317
+ }
1318
+ );
1319
+ }
1320
+ },
1321
+ function (results) {
1322
+ complete(results);
1323
+ }
1324
+ );
1325
+ },
1326
+ getType: function getType(rule) {
1327
+ if (rule.type === undefined && rule.pattern instanceof RegExp) {
1328
+ rule.type = 'pattern';
1329
+ }
1330
+
1331
+ if (typeof rule.validator !== 'function' && rule.type && !validators.hasOwnProperty(rule.type)) {
1332
+ throw new Error(format('Unknown rule type %s', rule.type));
1333
+ }
1334
+
1335
+ return rule.type || 'string';
1336
+ },
1337
+ getValidationMethod: function getValidationMethod(rule) {
1338
+ if (typeof rule.validator === 'function') {
1339
+ return rule.validator;
1340
+ }
1341
+
1342
+ var keys = Object.keys(rule);
1343
+ var messageIndex = keys.indexOf('message');
1344
+
1345
+ if (messageIndex !== -1) {
1346
+ keys.splice(messageIndex, 1);
1347
+ }
1348
+
1349
+ if (keys.length === 1 && keys[0] === 'required') {
1350
+ return validators.required;
1351
+ }
1352
+
1353
+ return validators[this.getType(rule)] || false;
1354
+ }
1355
+ };
1356
+
1357
+ Schema.register = function register(type, validator) {
1358
+ if (typeof validator !== 'function') {
1359
+ throw new Error('Cannot register a validator by type, validator is not a function');
1360
+ }
1361
+
1362
+ validators[type] = validator;
1363
+ };
1364
+
1365
+ Schema.warning = warning;
1366
+ Schema.messages = messages;
1367
+
1368
+ export default Schema;