@opentiny/vue-renderless 3.21.2 → 3.22.0
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.
- package/amount/index.js +4 -4
- package/anchor/index.js +1 -1
- package/async-flowchart/index.js +1 -1
- package/autocomplete/index.js +1 -1
- package/autocomplete/vue.js +3 -3
- package/base-select/index.js +19 -19
- package/base-select/vue.js +2 -2
- package/calendar/index.js +2 -2
- package/calendar-bar/index.js +2 -2
- package/calendar-bar/vue.js +1 -1
- package/calendar-view/index.js +66 -22
- package/calendar-view/vue.js +2 -3
- package/card/index.js +1 -1
- package/card-template/index.js +1 -1
- package/carousel/index.js +4 -4
- package/carousel/vue.js +1 -1
- package/cascader/index.js +21 -11
- package/cascader/vue.js +6 -5
- package/cascader-menu/vue.js +2 -2
- package/cascader-mobile/index.js +1 -1
- package/cascader-panel/index.js +4 -4
- package/cascader-panel/node.js +3 -4
- package/cascader-panel/vue.js +1 -1
- package/cascader-select/column-index.js +2 -2
- package/cascader-view/index.js +1 -1
- package/chart-bar/index.js +1 -1
- package/chart-candle/index.js +1 -1
- package/chart-core/deps/utils.js +6 -6
- package/chart-core/index.js +1 -1
- package/chart-funnel/index.js +1 -1
- package/chart-gauge/index.js +1 -1
- package/chart-line/index.js +1 -1
- package/chart-map/index.js +1 -1
- package/chart-pie/index.js +1 -1
- package/chart-radar/index.js +1 -1
- package/chart-sankey/index.js +1 -1
- package/chart-scatter/index.js +1 -1
- package/chart-waterfall/index.js +1 -1
- package/chart-wordcloud/index.js +1 -1
- package/checkbox/index.js +1 -1
- package/collapse-item/vue.js +1 -1
- package/column-list-item/index.js +1 -1
- package/common/deps/dom.js +20 -196
- package/common/deps/infinite-scroll.js +4 -43
- package/common/deps/popup-manager.js +1 -200
- package/container/index.js +2 -2
- package/crop/index.js +3 -3
- package/currency/index.js +2 -2
- package/date-panel/index.js +75 -25
- package/date-panel/vue.js +53 -21
- package/date-picker/vue.js +1 -1
- package/date-picker-mobile/index.js +1 -1
- package/date-range/index.js +71 -37
- package/date-range/vue.js +27 -23
- package/date-table/index.js +8 -5
- package/date-table/vue.js +1 -1
- package/dialog-box/index.js +3 -3
- package/dialog-box/vue.js +1 -1
- package/dialog-select/vue.js +7 -4
- package/drawer/index.js +2 -2
- package/drop-times/index.js +1 -1
- package/dropdown/index.js +11 -3
- package/dropdown/vue.js +2 -2
- package/dropdown-item/index.js +1 -1
- package/dropdown-item/mf.js +1 -1
- package/dropdown-menu/index.js +1 -1
- package/espace/vue.js +2 -2
- package/fall-menu/index.js +3 -3
- package/file-upload/index.js +16 -13
- package/file-upload/vue.js +2 -2
- package/filter/vue.js +1 -1
- package/filter-panel/vue.js +1 -2
- package/floating-button/index.js +1 -1
- package/flowchart/index.js +3 -3
- package/flowchart/vue.js +1 -1
- package/fluent-editor/index.js +5 -7
- package/fluent-editor/options.js +2 -2
- package/form/index.js +20 -2
- package/form-item/index.js +6 -6
- package/fullscreen/index.js +1 -1
- package/fullscreen/vue.js +1 -1
- package/grid/plugins/export.js +2 -2
- package/grid/plugins/exportExcel.js +3 -3
- package/grid/plugins/resize.js +2 -2
- package/grid/static/base/helperEqualCompare.js +1 -1
- package/grid/static/base/isPlainObject.js +1 -1
- package/grid/utils/common.js +2 -2
- package/grid/utils/dom.js +12 -7
- package/grid/utils/event.js +4 -4
- package/hrapprover/index.js +1 -1
- package/image/index.js +3 -3
- package/image-viewer/index.js +4 -6
- package/input/index.js +2 -2
- package/input/vue.js +1 -1
- package/ip-address/index.js +17 -21
- package/ip-address/vue.js +1 -1
- package/link-menu/index.js +1 -1
- package/link-menu/vue.js +1 -1
- package/load-list/index.js +1 -1
- package/load-list/vue.js +4 -4
- package/loading/index.js +2 -2
- package/menu/vue.js +1 -1
- package/milestone/index.js +6 -45
- package/modal/index.js +5 -5
- package/month-range/index.js +45 -5
- package/month-range/vue.js +19 -15
- package/month-table/index.js +5 -5
- package/month-table/vue.js +1 -1
- package/nav-menu/index.js +7 -7
- package/notify/index.js +3 -3
- package/numeric/index.js +5 -5
- package/option/index.js +1 -1
- package/option/vue.js +2 -1
- package/package.json +3 -2
- package/pager/index.js +28 -16
- package/pager/vue.js +27 -16
- package/panel/index.js +1 -1
- package/picker/index.js +11 -11
- package/picker/vue.js +2 -2
- package/picker-column/index.js +1 -1
- package/pop-upload/vue.js +1 -1
- package/popconfirm/vue.js +1 -1
- package/popeditor/index.js +6 -6
- package/popeditor/vue.js +2 -2
- package/popover/index.js +3 -3
- package/popover/vue.js +1 -1
- package/popup/index.js +3 -3
- package/pull-refresh/index.js +1 -1
- package/pull-refresh-mobile-first/index.js +1 -1
- package/pull-refresh-mobile-first/vue.js +4 -4
- package/quarter-panel/index.js +2 -2
- package/quarter-panel/vue.js +1 -1
- package/radio-group/index.js +1 -1
- package/rate/index.js +1 -1
- package/rate/vue.js +1 -1
- package/recycle-scroller/index.js +2 -2
- package/recycle-scroller/vue.js +1 -1
- package/rich-text/index.js +1 -1
- package/rich-text/table-module.js +2 -2
- package/river/river.js +1 -1
- package/river/vue.js +1 -1
- package/scrollbar/vue-bar.js +1 -1
- package/scrollbar/vue.js +1 -1
- package/search/index.js +3 -3
- package/select/index.js +26 -22
- package/select/vue.js +8 -7
- package/select-dropdown/vue.js +5 -5
- package/selected-box/index.js +1 -1
- package/signature/index.js +1 -1
- package/signature/vue.js +2 -2
- package/skeleton/index.js +1 -1
- package/slider/index.js +4 -4
- package/slider-button-group/slide-button.js +2 -2
- package/split/index.js +2 -2
- package/split/vue.js +1 -1
- package/statistic/index.js +1 -1
- package/steps/index.js +2 -3
- package/steps/slide-bar.js +2 -2
- package/sticky/vue.js +4 -4
- package/tab-bar/index.js +2 -2
- package/tab-item-mf/vue.js +1 -1
- package/tab-nav/index.js +4 -4
- package/tabbar/index.js +1 -1
- package/tabbar/vue.js +1 -1
- package/tabbar-item/index.js +1 -1
- package/tabs-mf/index.js +5 -5
- package/tabs-mf/vue-bar.js +1 -1
- package/tabs-mf/vue-swipe.js +1 -1
- package/tabs-mf/vue.js +2 -2
- package/tabs-mf/wheel.js +3 -3
- package/tag-group/vue.js +2 -2
- package/tall-storage/index.js +1 -1
- package/tall-storage/vue.js +1 -1
- package/time/index.js +1 -1
- package/time/vue.js +1 -1
- package/time-line/index.js +1 -1
- package/time-line-new/index.js +1 -1
- package/time-panel/index.js +2 -2
- package/time-panel/vue.js +1 -1
- package/time-range/index.js +1 -1
- package/time-range/vue.js +1 -1
- package/time-spinner/index.js +4 -4
- package/time-spinner/vue.js +1 -1
- package/timeline-item/index.js +1 -1
- package/toggle-menu/index.js +1 -1
- package/tooltip/index.js +2 -2
- package/tooltip/vue.js +2 -2
- package/top-box/index.js +3 -3
- package/transfer/index.js +1 -1
- package/transfer-panel/index.js +1 -1
- package/tree/index.js +9 -9
- package/tree/vue.js +2 -2
- package/tree-node/index.js +1 -1
- package/tree-node/vue.js +1 -1
- package/tree-select/index.js +1 -1
- package/types/async-flowchart.type.d.ts +2 -14
- package/types/breadcrumb-item.type.d.ts +5 -1
- package/types/breadcrumb.type.d.ts +5 -1
- package/types/button-group.type.d.ts +5 -1
- package/types/button.type.d.ts +1 -1
- package/types/cascader.type.d.ts +6 -1
- package/types/date-table.type.d.ts +1 -120
- package/types/dropdown.type.d.ts +1 -1
- package/types/label.type.d.ts +1 -53
- package/types/loading.type.d.ts +12 -0
- package/types/numeric.type.d.ts +3 -22
- package/types/pager.type.d.ts +12 -7
- package/types/popconfirm.type.d.ts +2 -0
- package/types/steps.type.d.ts +1 -0
- package/types/tag-group.type.d.ts +2 -14
- package/types/tag.type.d.ts +4 -4
- package/types/tooltip.type.d.ts +3 -13
- package/types/user-head.type.d.ts +0 -4
- package/upload/index.js +1 -1
- package/upload-list/index.js +1 -1
- package/upload-list/vue.js +4 -4
- package/user/index.js +7 -7
- package/user/vue.js +15 -2
- package/user-contact/vue.js +2 -2
- package/virtual-scroll-box/index.js +2 -2
- package/wizard/index.js +3 -3
- package/year-range/index.js +61 -11
- package/year-range/vue.js +33 -20
- package/year-table/index.js +7 -5
- package/avatar/index.js +0 -30
- package/avatar/vue.js +0 -22
- package/common/array.js +0 -115
- package/common/bigInt.js +0 -315
- package/common/browser.js +0 -81
- package/common/calendar/calendar.js +0 -97
- package/common/dataset/index.js +0 -99
- package/common/date.js +0 -354
- package/common/decimal.js +0 -155
- package/common/deps/ResizeObserver.js +0 -456
- package/common/deps/after-leave.js +0 -27
- package/common/deps/clickoutside.js +0 -75
- package/common/deps/date-util.js +0 -255
- package/common/deps/date.js +0 -286
- package/common/deps/debounce.js +0 -8
- package/common/deps/eSpaceCtrl.js +0 -304
- package/common/deps/fastdom/async.js +0 -41
- package/common/deps/fastdom/index.js +0 -9
- package/common/deps/fastdom/sandbox.js +0 -53
- package/common/deps/fastdom/singleton.js +0 -88
- package/common/deps/fullscreen/apis.js +0 -143
- package/common/deps/fullscreen/screenfull.js +0 -165
- package/common/deps/memorize.js +0 -124
- package/common/deps/observe-visibility.js +0 -106
- package/common/deps/popper.js +0 -616
- package/common/deps/repeat-click.js +0 -29
- package/common/deps/resize-event.js +0 -39
- package/common/deps/scroll-into-view.js +0 -29
- package/common/deps/scrollbar-width.js +0 -33
- package/common/deps/throttle.js +0 -45
- package/common/deps/touch-emulator.js +0 -103
- package/common/deps/touch.js +0 -37
- package/common/deps/tree-model/node.js +0 -475
- package/common/deps/tree-model/tree-store.js +0 -312
- package/common/deps/tree-model/util.js +0 -24
- package/common/deps/upload-ajax.js +0 -81
- package/common/deps/useEventListener.js +0 -54
- package/common/deps/useInstanceSlots.js +0 -22
- package/common/deps/useRect.js +0 -25
- package/common/deps/useRelation.js +0 -89
- package/common/deps/useTouch.js +0 -68
- package/common/deps/useUserAgent.js +0 -16
- package/common/deps/useWindowSize.js +0 -23
- package/common/deps/vue-emitter.js +0 -34
- package/common/deps/vue-popper.js +0 -180
- package/common/deps/vue-popup.js +0 -138
- package/common/event.js +0 -46
- package/common/form/const.js +0 -10
- package/common/function.js +0 -28
- package/common/global.js +0 -11
- package/common/index.js +0 -259
- package/common/object.js +0 -227
- package/common/prop-util.js +0 -43
- package/common/runtime.js +0 -79
- package/common/string.js +0 -417
- package/common/type.js +0 -66
- package/common/validate/index.js +0 -10
- package/common/validate/messages.js +0 -65
- package/common/validate/rules/enum.js +0 -12
- package/common/validate/rules/index.js +0 -18
- package/common/validate/rules/pattern.js +0 -20
- package/common/validate/rules/range.js +0 -52
- package/common/validate/rules/required.js +0 -11
- package/common/validate/rules/type.js +0 -100
- package/common/validate/rules/whitespace.js +0 -10
- package/common/validate/schema.js +0 -290
- package/common/validate/util.js +0 -211
- package/common/validate/validations/array.js +0 -22
- package/common/validate/validations/date.js +0 -31
- package/common/validate/validations/enum.js +0 -22
- package/common/validate/validations/float.js +0 -22
- package/common/validate/validations/index.js +0 -46
- package/common/validate/validations/integer.js +0 -22
- package/common/validate/validations/method.js +0 -21
- package/common/validate/validations/number.js +0 -25
- package/common/validate/validations/pattern.js +0 -21
- package/common/validate/validations/required.js +0 -11
- package/common/validate/validations/string.js +0 -33
- package/common/validate/validations/type.js +0 -29
- package/index-bar/index.js +0 -66
- package/index-bar/vue.js +0 -73
- package/index-bar-anchor/vue.js +0 -16
- package/label/index.js +0 -56
- package/label/vue.js +0 -26
- package/list/index.js +0 -13
- package/list/vue.js +0 -17
- package/mask/index.js +0 -13
- package/mask/vue.js +0 -18
- package/mini-picker/index.js +0 -165
- package/mini-picker/vue.js +0 -122
- package/multi-select/index.js +0 -394
- package/multi-select/vue.js +0 -113
- package/multi-select-item/index.js +0 -23
- package/multi-select-item/vue.js +0 -31
- package/toast/index.js +0 -7
- package/toast/vue.js +0 -19
- package/types/toast.type.d.ts +0 -63
- package/wheel/index.js +0 -165
- package/wheel/vue.js +0 -79
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
import "../../../chunk-G2ADBYYC.js";
|
|
2
|
-
import * as util from "../util";
|
|
3
|
-
import required from "./required";
|
|
4
|
-
import { format } from "../../date";
|
|
5
|
-
import { isNullOrEmpty } from "../../string";
|
|
6
|
-
import { isNumber, isObject, isDate, typeOf } from "../../type";
|
|
7
|
-
const emailReg1 = '^(([^<>()\\[\\]\\\\.,;:\\s@"]+(\\.[^<>()\\[\\]\\\\.,;:\\s@"]+)*)|(".+"))';
|
|
8
|
-
const emailReg = new RegExp(
|
|
9
|
-
emailReg1 + "@((\\[[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,6}))$"
|
|
10
|
-
);
|
|
11
|
-
const pattern = {
|
|
12
|
-
acceptImg: /\.(png|jpe?g|gif)$/,
|
|
13
|
-
acceptFile: /\.(doc?x|xls?x|ppt?x|txt)$/,
|
|
14
|
-
email: emailReg,
|
|
15
|
-
fileSize: /^\d+(\.\d+)?[KMGTPEZY]?B$/i,
|
|
16
|
-
hex: /^#?([a-f0-9]{6}|[a-f0-9]{3})$/i,
|
|
17
|
-
speczh: /^[0-9a-zA-Z_\u4E00-\u9FA5]+$/,
|
|
18
|
-
specialch: /^[0-9a-zA-Z_\-.]+$/,
|
|
19
|
-
specialch2: /^[0-9a-zA-Z_-]+$/,
|
|
20
|
-
url: /^(([a-zA-Z]{3,}):)?\/\/([\w-]+\.)+[\w]+(\/[a-zA-Z- ./?%&=]*)?/i,
|
|
21
|
-
version: /^\d+\.\d+(\.\d+)*$/
|
|
22
|
-
};
|
|
23
|
-
const types = {
|
|
24
|
-
integer: (value) => types.number(value) && /^[-]?[\d]+$/.test(value),
|
|
25
|
-
float: (value) => types.number(value) && !types.integer(value),
|
|
26
|
-
array: Array.isArray,
|
|
27
|
-
regexp(value) {
|
|
28
|
-
if (value instanceof RegExp) {
|
|
29
|
-
return true;
|
|
30
|
-
}
|
|
31
|
-
try {
|
|
32
|
-
return !!new RegExp(value);
|
|
33
|
-
} catch (e) {
|
|
34
|
-
return false;
|
|
35
|
-
}
|
|
36
|
-
},
|
|
37
|
-
date: isDate,
|
|
38
|
-
number: (value) => isNumber(Number(value)),
|
|
39
|
-
object: (value) => isObject(value) && !types.array(value),
|
|
40
|
-
method: (value) => typeOf(value) === "function",
|
|
41
|
-
email: (value) => isNullOrEmpty(value) || !!value.match(pattern.email) && value.length < 255,
|
|
42
|
-
url: (value) => isNullOrEmpty(value) || !!value.match(pattern.url),
|
|
43
|
-
hex: (value) => isNullOrEmpty(value) || !!value.match(pattern.hex),
|
|
44
|
-
digits: (value) => isNullOrEmpty(value) || /^\d+$/.test(value),
|
|
45
|
-
time: (value) => isNullOrEmpty(value) || /^((0)[0-9]|1[0-9]|20|21|22|23):([0-5][0-9])$/.test(value),
|
|
46
|
-
dateYM: (value) => isNullOrEmpty(value) || format(value, "yyyy-MM") === value,
|
|
47
|
-
dateYMD: (value) => isNullOrEmpty(value) || format(value, "yyyy-MM-dd") === value,
|
|
48
|
-
dateTime: (value) => isNullOrEmpty(value) || format(value, "yyyy-MM-dd hh:mm") === value,
|
|
49
|
-
longDateTime: (value) => isNullOrEmpty(value) || format(value, "yyyy-MM-dd hh:mm:ss") === value,
|
|
50
|
-
version: (value) => isNullOrEmpty(value) || !!value.match(pattern.version),
|
|
51
|
-
speczh: (value) => isNullOrEmpty(value) || !!value.match(pattern.speczh),
|
|
52
|
-
specialch: (value) => isNullOrEmpty(value) || !!value.match(pattern.specialch),
|
|
53
|
-
specialch2: (value) => isNullOrEmpty(value) || !!value.match(pattern.specialch2),
|
|
54
|
-
acceptImg: (value) => isNullOrEmpty(value) || !!value.match(pattern.acceptImg),
|
|
55
|
-
acceptFile: (value) => isNullOrEmpty(value) || !!value.match(pattern.acceptFile),
|
|
56
|
-
fileSize: (value) => isNullOrEmpty(value) || !!value.match(pattern.fileSize)
|
|
57
|
-
};
|
|
58
|
-
function type_default(rule, value, source, errors, options) {
|
|
59
|
-
if (rule.required && value === void 0) {
|
|
60
|
-
required(rule, value, source, errors, options);
|
|
61
|
-
return;
|
|
62
|
-
}
|
|
63
|
-
const custom = [
|
|
64
|
-
"array",
|
|
65
|
-
"acceptImg",
|
|
66
|
-
"acceptFile",
|
|
67
|
-
"date",
|
|
68
|
-
"digits",
|
|
69
|
-
"dateTime",
|
|
70
|
-
"dateYM",
|
|
71
|
-
"dateYMD",
|
|
72
|
-
"email",
|
|
73
|
-
"float",
|
|
74
|
-
"fileSize",
|
|
75
|
-
"hex",
|
|
76
|
-
"integer",
|
|
77
|
-
"longDateTime",
|
|
78
|
-
"method",
|
|
79
|
-
"number",
|
|
80
|
-
"object",
|
|
81
|
-
"regexp",
|
|
82
|
-
"speczh",
|
|
83
|
-
"specialch",
|
|
84
|
-
"specialch2",
|
|
85
|
-
"time",
|
|
86
|
-
"version",
|
|
87
|
-
"url"
|
|
88
|
-
];
|
|
89
|
-
const ruleType = rule.type;
|
|
90
|
-
if (custom.includes(ruleType)) {
|
|
91
|
-
if (!types[ruleType](value)) {
|
|
92
|
-
errors.push(util.format(options.messages.types[ruleType], "", rule.type));
|
|
93
|
-
}
|
|
94
|
-
} else if (ruleType && typeof value !== rule.type) {
|
|
95
|
-
errors.push(util.format(options.messages.types[ruleType], "", rule.type));
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
export {
|
|
99
|
-
type_default as default
|
|
100
|
-
};
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import "../../../chunk-G2ADBYYC.js";
|
|
2
|
-
import * as util from "../util";
|
|
3
|
-
function whitespace_default(rule, checkValue, source, errors, options) {
|
|
4
|
-
if (/^\s+$/.test(checkValue) || checkValue === "") {
|
|
5
|
-
errors.push(util.format(options.messages.whitespace, ""));
|
|
6
|
-
}
|
|
7
|
-
}
|
|
8
|
-
export {
|
|
9
|
-
whitespace_default as default
|
|
10
|
-
};
|
|
@@ -1,290 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
__spreadProps,
|
|
3
|
-
__spreadValues
|
|
4
|
-
} from "../../chunk-G2ADBYYC.js";
|
|
5
|
-
import { format, complementError, asyncMap, warning, deepMerge, convertFieldsError } from "./util";
|
|
6
|
-
import { hasOwn, isFunction } from "../type";
|
|
7
|
-
function Schema(descriptor, translate) {
|
|
8
|
-
Schema.getSystemMessage = () => Schema.getDefaultMessage(translate);
|
|
9
|
-
Schema.messages = Schema.getSystemMessage(translate);
|
|
10
|
-
Schema.systemMessages = Schema.messages;
|
|
11
|
-
this.rules = null;
|
|
12
|
-
this._messages = Schema.systemMessages;
|
|
13
|
-
this.define(descriptor);
|
|
14
|
-
}
|
|
15
|
-
const getCompleteFn = (validCallback) => (results) => {
|
|
16
|
-
let idx;
|
|
17
|
-
let errors = [];
|
|
18
|
-
let fields = {};
|
|
19
|
-
function addValid(eror) {
|
|
20
|
-
if (Array.isArray(eror)) {
|
|
21
|
-
errors = errors.concat(...eror);
|
|
22
|
-
} else {
|
|
23
|
-
errors.push(eror);
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
for (idx = 0; idx < results.length; idx++) {
|
|
27
|
-
addValid(results[idx]);
|
|
28
|
-
}
|
|
29
|
-
if (errors.length) {
|
|
30
|
-
fields = convertFieldsError(errors);
|
|
31
|
-
} else {
|
|
32
|
-
errors = null;
|
|
33
|
-
fields = null;
|
|
34
|
-
}
|
|
35
|
-
validCallback(errors, fields);
|
|
36
|
-
};
|
|
37
|
-
const isDeep = (rule, data) => {
|
|
38
|
-
let deep = (rule.type === "object" || rule.type === "array") && (typeof rule.fields === "object" || typeof rule.defaultField === "object");
|
|
39
|
-
deep = deep && (rule.required || !rule.required && data.value);
|
|
40
|
-
return deep;
|
|
41
|
-
};
|
|
42
|
-
const getFieldsSchema = (rule, data) => {
|
|
43
|
-
let schema = {};
|
|
44
|
-
function addFullfield(key, item) {
|
|
45
|
-
return __spreadProps(__spreadValues({}, item), {
|
|
46
|
-
fullField: `${rule.fullField}.${key}`
|
|
47
|
-
});
|
|
48
|
-
}
|
|
49
|
-
if (rule.defaultField) {
|
|
50
|
-
for (const k in data.value) {
|
|
51
|
-
if (hasOwn.call(data.value, k)) {
|
|
52
|
-
schema[k] = rule.defaultField;
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
schema = __spreadValues(__spreadValues({}, schema), data.rule.fields);
|
|
57
|
-
for (const f in schema) {
|
|
58
|
-
if (hasOwn.call(schema, f)) {
|
|
59
|
-
const fieldSchema = Array.isArray(schema[f]) ? schema[f] : [schema[f]];
|
|
60
|
-
schema[f] = fieldSchema.map(addFullfield.bind(null, f));
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
return schema;
|
|
64
|
-
};
|
|
65
|
-
const arrayed = (failds) => {
|
|
66
|
-
if (!Array.isArray(failds)) {
|
|
67
|
-
failds = [failds];
|
|
68
|
-
}
|
|
69
|
-
return failds;
|
|
70
|
-
};
|
|
71
|
-
const getRequiredErrorFeilds = ({ rule, failds, options }) => {
|
|
72
|
-
if (rule.message) {
|
|
73
|
-
failds = [].concat(rule.message).map(complementError(rule));
|
|
74
|
-
} else if (options.error) {
|
|
75
|
-
failds = [options.error(rule, format(options.messages.required, rule.field))];
|
|
76
|
-
} else {
|
|
77
|
-
failds = [];
|
|
78
|
-
}
|
|
79
|
-
return failds;
|
|
80
|
-
};
|
|
81
|
-
const setDataRuleOptions = ({ data, options }) => {
|
|
82
|
-
if (data.rule.options) {
|
|
83
|
-
let { messages, error } = options;
|
|
84
|
-
Object.assign(data.rule.options, { messages, error });
|
|
85
|
-
}
|
|
86
|
-
};
|
|
87
|
-
const getValidateCallback = ({ failds, doIt }) => (errs) => {
|
|
88
|
-
const finalErrors = [];
|
|
89
|
-
if (failds && failds.length) {
|
|
90
|
-
finalErrors.push(...failds);
|
|
91
|
-
}
|
|
92
|
-
if (errs && errs.length) {
|
|
93
|
-
finalErrors.push(...errs);
|
|
94
|
-
}
|
|
95
|
-
doIt(finalErrors.length ? finalErrors : null);
|
|
96
|
-
};
|
|
97
|
-
const asyncCallback = (options, rule, errorFields, doIt, data) => (e = []) => {
|
|
98
|
-
let failds = e;
|
|
99
|
-
const deep = isDeep(rule, data);
|
|
100
|
-
failds = arrayed(failds);
|
|
101
|
-
if (!options.suppressWarning && failds.length) {
|
|
102
|
-
Schema.warning("async-validator:", failds);
|
|
103
|
-
}
|
|
104
|
-
if (failds.length && rule.message) {
|
|
105
|
-
failds = [].concat(rule.message);
|
|
106
|
-
}
|
|
107
|
-
failds = failds.map(complementError(rule));
|
|
108
|
-
if (options.first && failds.length) {
|
|
109
|
-
errorFields[rule.field] = 1;
|
|
110
|
-
return doIt(failds);
|
|
111
|
-
}
|
|
112
|
-
if (deep) {
|
|
113
|
-
if (rule.required && !data.value) {
|
|
114
|
-
failds = getRequiredErrorFeilds({ rule, failds, options });
|
|
115
|
-
return doIt(failds);
|
|
116
|
-
}
|
|
117
|
-
const schema = new Schema(getFieldsSchema(rule, data));
|
|
118
|
-
schema.messages(options.messages);
|
|
119
|
-
setDataRuleOptions({ data, options });
|
|
120
|
-
schema.validate(data.value, data.rule.options || options, getValidateCallback({ failds, doIt }));
|
|
121
|
-
} else {
|
|
122
|
-
doIt(failds);
|
|
123
|
-
}
|
|
124
|
-
};
|
|
125
|
-
Schema.prototype = {
|
|
126
|
-
messages(messages) {
|
|
127
|
-
if (messages) {
|
|
128
|
-
this._messages = deepMerge(Schema.getSystemMessage(), messages);
|
|
129
|
-
}
|
|
130
|
-
return this._messages;
|
|
131
|
-
},
|
|
132
|
-
/** 格式化检验规则并添加到实例上。
|
|
133
|
-
* rules格式化后的数据结构: { key: [ { type: 'xx', ...others } ] }
|
|
134
|
-
*/
|
|
135
|
-
define(rules) {
|
|
136
|
-
if (!rules) {
|
|
137
|
-
throw new Error("Cannot configure a schema with no rules");
|
|
138
|
-
}
|
|
139
|
-
if (Array.isArray(rules) || typeof rules !== "object") {
|
|
140
|
-
throw new TypeError("Rules must be an object");
|
|
141
|
-
}
|
|
142
|
-
this.rules = {};
|
|
143
|
-
let rule;
|
|
144
|
-
Object.keys(rules).forEach((key) => {
|
|
145
|
-
if (hasOwn.call(rules, key)) {
|
|
146
|
-
rule = rules[key];
|
|
147
|
-
this.rules[key] = Array.isArray(rule) ? rule : [rule];
|
|
148
|
-
}
|
|
149
|
-
});
|
|
150
|
-
},
|
|
151
|
-
/** 将检验规则和源数据合并转化成新数据
|
|
152
|
-
* rules: { key: [rule1, rule2] }, source: { key: sourceData, key2: sourceData2 }
|
|
153
|
-
* series { key: [{ rule: rule1, value: sourceData, source, field: key }, ...] }
|
|
154
|
-
*/
|
|
155
|
-
getSeries(options, source, source_) {
|
|
156
|
-
let arr;
|
|
157
|
-
let value;
|
|
158
|
-
const series = {};
|
|
159
|
-
const keys = options.keys || Object.keys(this.rules);
|
|
160
|
-
keys.forEach((key) => {
|
|
161
|
-
arr = this.rules[key];
|
|
162
|
-
value = source[key];
|
|
163
|
-
arr.forEach((r) => {
|
|
164
|
-
let rule = r;
|
|
165
|
-
if (typeof rule.transform === "function") {
|
|
166
|
-
if (source === source_) {
|
|
167
|
-
source = __spreadValues({}, source);
|
|
168
|
-
}
|
|
169
|
-
source[key] = rule.transform(value);
|
|
170
|
-
value = source[key];
|
|
171
|
-
}
|
|
172
|
-
if (typeof rule === "function") {
|
|
173
|
-
rule = { validator: rule };
|
|
174
|
-
} else {
|
|
175
|
-
rule = __spreadValues({}, rule);
|
|
176
|
-
}
|
|
177
|
-
rule.validator = this.getValidationMethod(rule);
|
|
178
|
-
rule.field = key;
|
|
179
|
-
rule.fullField = rule.fullField || key;
|
|
180
|
-
rule.type = this.getType(rule);
|
|
181
|
-
options.custom && Object.assign(rule, options.custom);
|
|
182
|
-
if (!rule.validator) {
|
|
183
|
-
return;
|
|
184
|
-
}
|
|
185
|
-
series[key] = series[key] || [];
|
|
186
|
-
series[key].push({ rule, value, source, field: key });
|
|
187
|
-
});
|
|
188
|
-
});
|
|
189
|
-
return series;
|
|
190
|
-
},
|
|
191
|
-
mergeMessage(options) {
|
|
192
|
-
if (options.messages) {
|
|
193
|
-
let messages = this.messages();
|
|
194
|
-
if (messages === Schema.systemMessages) {
|
|
195
|
-
messages = Schema.getSystemMessage();
|
|
196
|
-
}
|
|
197
|
-
deepMerge(messages, options.messages);
|
|
198
|
-
options.messages = messages;
|
|
199
|
-
} else {
|
|
200
|
-
options.messages = this.messages();
|
|
201
|
-
}
|
|
202
|
-
},
|
|
203
|
-
validate(source_, o = {}, oc = () => void 0) {
|
|
204
|
-
let source = source_;
|
|
205
|
-
let options = o;
|
|
206
|
-
let validCallback = oc;
|
|
207
|
-
if (typeof options === "function") {
|
|
208
|
-
validCallback = options;
|
|
209
|
-
options = {};
|
|
210
|
-
}
|
|
211
|
-
if (!this.rules || Object.keys(this.rules).length === 0) {
|
|
212
|
-
validCallback && validCallback();
|
|
213
|
-
return Promise.resolve();
|
|
214
|
-
}
|
|
215
|
-
const complete = getCompleteFn(validCallback);
|
|
216
|
-
this.mergeMessage(options);
|
|
217
|
-
const seriesData = this.getSeries(options, source, source_);
|
|
218
|
-
const errorFields = {};
|
|
219
|
-
return asyncMap(
|
|
220
|
-
seriesData,
|
|
221
|
-
options,
|
|
222
|
-
(data, doIt) => {
|
|
223
|
-
const rule = data.rule;
|
|
224
|
-
const validHandler = asyncCallback(options, rule, errorFields, doIt, data);
|
|
225
|
-
let validResult;
|
|
226
|
-
if (rule.asyncValidator) {
|
|
227
|
-
validResult = rule.asyncValidator(rule, data.value, validHandler, data.source, options);
|
|
228
|
-
} else if (rule.validator) {
|
|
229
|
-
validResult = rule.validator(rule, data.value, validHandler, data.source, options);
|
|
230
|
-
if (validResult === true) {
|
|
231
|
-
validHandler();
|
|
232
|
-
} else if (validResult === false) {
|
|
233
|
-
validHandler(rule.message || `${rule.field} fails`);
|
|
234
|
-
} else if (Array.isArray(validResult)) {
|
|
235
|
-
validHandler(validResult);
|
|
236
|
-
} else if (validResult instanceof Error) {
|
|
237
|
-
validHandler(validResult.message);
|
|
238
|
-
}
|
|
239
|
-
}
|
|
240
|
-
if (validResult && validResult.then) {
|
|
241
|
-
validResult.then(
|
|
242
|
-
() => validHandler(),
|
|
243
|
-
(e) => validHandler(e)
|
|
244
|
-
);
|
|
245
|
-
}
|
|
246
|
-
},
|
|
247
|
-
(results) => {
|
|
248
|
-
complete(results);
|
|
249
|
-
}
|
|
250
|
-
);
|
|
251
|
-
},
|
|
252
|
-
getValidationMethod(rule) {
|
|
253
|
-
if (isFunction(rule.validator)) {
|
|
254
|
-
return rule.validator;
|
|
255
|
-
}
|
|
256
|
-
const ruleKeys = Object.keys(rule);
|
|
257
|
-
const messageIndex = ruleKeys.indexOf("message");
|
|
258
|
-
if (messageIndex > -1) {
|
|
259
|
-
ruleKeys.splice(messageIndex, 1);
|
|
260
|
-
}
|
|
261
|
-
if (ruleKeys.length === 1 && ruleKeys[0] === "required") {
|
|
262
|
-
return Schema.validators.required;
|
|
263
|
-
}
|
|
264
|
-
return Schema.validators[this.getType(rule)] || false;
|
|
265
|
-
},
|
|
266
|
-
getType(rule) {
|
|
267
|
-
if (rule.type === void 0 && rule.pattern instanceof RegExp) {
|
|
268
|
-
rule.type = "pattern";
|
|
269
|
-
}
|
|
270
|
-
if (typeof rule.validator !== "function" && rule.type && !hasOwn.call(Schema.validators, rule.type)) {
|
|
271
|
-
throw new Error(format("Unknown rule type %s", rule.type));
|
|
272
|
-
}
|
|
273
|
-
return rule.type || "string";
|
|
274
|
-
}
|
|
275
|
-
};
|
|
276
|
-
Schema.register = (type, validator) => {
|
|
277
|
-
if (typeof validator !== "function") {
|
|
278
|
-
throw new TypeError("Cannot register a validator by type, validator is not a function");
|
|
279
|
-
}
|
|
280
|
-
Schema.validators[type] = validator;
|
|
281
|
-
};
|
|
282
|
-
Schema.validators = {};
|
|
283
|
-
Schema.warning = warning;
|
|
284
|
-
Schema.messages = {};
|
|
285
|
-
Schema.systemMessages = {};
|
|
286
|
-
Schema.getDefaultMessage = () => void 0;
|
|
287
|
-
var schema_default = Schema;
|
|
288
|
-
export {
|
|
289
|
-
schema_default as default
|
|
290
|
-
};
|
package/common/validate/util.js
DELETED
|
@@ -1,211 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
__spreadValues
|
|
3
|
-
} from "../../chunk-G2ADBYYC.js";
|
|
4
|
-
import { hasOwn, isNull } from "../type";
|
|
5
|
-
import { log } from "@opentiny/utils";
|
|
6
|
-
const formatRegExp = /%[sdj%]/g;
|
|
7
|
-
const warning = () => void 0;
|
|
8
|
-
function convertFieldsError(errors) {
|
|
9
|
-
if (!errors || !errors.length) {
|
|
10
|
-
return null;
|
|
11
|
-
}
|
|
12
|
-
const fields = {};
|
|
13
|
-
errors.forEach((error) => {
|
|
14
|
-
const field = error.field;
|
|
15
|
-
fields[field] = fields[field] || [];
|
|
16
|
-
fields[field].push(error);
|
|
17
|
-
});
|
|
18
|
-
return fields;
|
|
19
|
-
}
|
|
20
|
-
function format(i18nTemplate, ...rest) {
|
|
21
|
-
if (typeof i18nTemplate === "function") {
|
|
22
|
-
return i18nTemplate(...rest);
|
|
23
|
-
}
|
|
24
|
-
if (typeof i18nTemplate === "string") {
|
|
25
|
-
let i = 0;
|
|
26
|
-
const len = rest.length;
|
|
27
|
-
let str = String(i18nTemplate).replace(formatRegExp, (matchChar) => {
|
|
28
|
-
if (matchChar === "%%") {
|
|
29
|
-
return "%";
|
|
30
|
-
}
|
|
31
|
-
if (i >= len) {
|
|
32
|
-
return matchChar;
|
|
33
|
-
}
|
|
34
|
-
switch (matchChar) {
|
|
35
|
-
case "%j":
|
|
36
|
-
try {
|
|
37
|
-
return JSON.stringify(rest[i++]);
|
|
38
|
-
} catch (e) {
|
|
39
|
-
return "[Circular]";
|
|
40
|
-
}
|
|
41
|
-
case "%d":
|
|
42
|
-
return Number(rest[i++]);
|
|
43
|
-
case "%s":
|
|
44
|
-
return String(rest[i++]);
|
|
45
|
-
default:
|
|
46
|
-
return matchChar;
|
|
47
|
-
}
|
|
48
|
-
});
|
|
49
|
-
return str;
|
|
50
|
-
}
|
|
51
|
-
return i18nTemplate;
|
|
52
|
-
}
|
|
53
|
-
function isNativeStringType(type) {
|
|
54
|
-
return [
|
|
55
|
-
"string",
|
|
56
|
-
"url",
|
|
57
|
-
"hex",
|
|
58
|
-
"email",
|
|
59
|
-
"pattern",
|
|
60
|
-
"digits",
|
|
61
|
-
"time",
|
|
62
|
-
"dateYMD",
|
|
63
|
-
"longDateTime",
|
|
64
|
-
"dateTime",
|
|
65
|
-
"dateYM",
|
|
66
|
-
"version",
|
|
67
|
-
"speczh",
|
|
68
|
-
"specialch",
|
|
69
|
-
"specialch2",
|
|
70
|
-
"acceptImg",
|
|
71
|
-
"acceptFile",
|
|
72
|
-
"fileSize"
|
|
73
|
-
].includes(type);
|
|
74
|
-
}
|
|
75
|
-
function isEmptyValue(data, dataType) {
|
|
76
|
-
if (isNull(data)) {
|
|
77
|
-
return true;
|
|
78
|
-
}
|
|
79
|
-
if (dataType === "array" && Array.isArray(data) && !data.length) {
|
|
80
|
-
return true;
|
|
81
|
-
}
|
|
82
|
-
if (isNativeStringType(dataType) && typeof data === "string" && !data) {
|
|
83
|
-
return true;
|
|
84
|
-
}
|
|
85
|
-
return false;
|
|
86
|
-
}
|
|
87
|
-
function isEmptyObject(data) {
|
|
88
|
-
return Object.keys(data).length === 0;
|
|
89
|
-
}
|
|
90
|
-
function asyncParallelArray(arrData, func, callback) {
|
|
91
|
-
let count = 0;
|
|
92
|
-
const results = [];
|
|
93
|
-
const arrLength = arrData.length;
|
|
94
|
-
function checkCount(errors) {
|
|
95
|
-
results.push(...errors);
|
|
96
|
-
count++;
|
|
97
|
-
if (count === arrLength) {
|
|
98
|
-
callback(results);
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
arrData.forEach((rule) => {
|
|
102
|
-
func(rule, checkCount);
|
|
103
|
-
});
|
|
104
|
-
}
|
|
105
|
-
function asyncSerialArray(arr, fn, cb) {
|
|
106
|
-
let idx = 0;
|
|
107
|
-
const arrLength = arr.length;
|
|
108
|
-
function checkNext(errorList) {
|
|
109
|
-
if (errorList && errorList.length) {
|
|
110
|
-
cb(errorList);
|
|
111
|
-
return;
|
|
112
|
-
}
|
|
113
|
-
const original = idx;
|
|
114
|
-
idx = idx + 1;
|
|
115
|
-
if (original < arrLength) {
|
|
116
|
-
fn(arr[original], checkNext);
|
|
117
|
-
} else {
|
|
118
|
-
cb([]);
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
checkNext([]);
|
|
122
|
-
}
|
|
123
|
-
function flattenObjArr(objArr) {
|
|
124
|
-
const result = [];
|
|
125
|
-
Object.keys(objArr).forEach((item) => {
|
|
126
|
-
result.push(...objArr[item]);
|
|
127
|
-
});
|
|
128
|
-
return result;
|
|
129
|
-
}
|
|
130
|
-
function asyncMap(objArray, option, func, callback) {
|
|
131
|
-
if (option.first) {
|
|
132
|
-
const pending2 = new Promise((resolve, reject) => {
|
|
133
|
-
const errorFn = reject;
|
|
134
|
-
const next = (errors) => {
|
|
135
|
-
callback(errors);
|
|
136
|
-
return errors.length ? errorFn({ errors, fields: convertFieldsError(errors) }) : resolve();
|
|
137
|
-
};
|
|
138
|
-
const flattenArr = flattenObjArr(objArray);
|
|
139
|
-
asyncSerialArray(flattenArr, func, next);
|
|
140
|
-
});
|
|
141
|
-
pending2.catch((error) => error.errors && error.fields || log.logger.error(error));
|
|
142
|
-
return pending2;
|
|
143
|
-
}
|
|
144
|
-
let firstFields = option.firstFields || [];
|
|
145
|
-
if (firstFields === true) {
|
|
146
|
-
firstFields = Object.keys(objArray);
|
|
147
|
-
}
|
|
148
|
-
let total = 0;
|
|
149
|
-
const objArrayKeys = Object.keys(objArray);
|
|
150
|
-
const objArrLength = objArrayKeys.length;
|
|
151
|
-
const results = [];
|
|
152
|
-
const pending = new Promise((resolve, reject) => {
|
|
153
|
-
const errorFn = reject;
|
|
154
|
-
const next = (errors) => {
|
|
155
|
-
results.push(...errors);
|
|
156
|
-
total++;
|
|
157
|
-
if (total === objArrLength) {
|
|
158
|
-
callback(results);
|
|
159
|
-
return results.length ? errorFn({ errors: results, fields: convertFieldsError(results) }) : resolve();
|
|
160
|
-
}
|
|
161
|
-
};
|
|
162
|
-
objArrayKeys.forEach((key) => {
|
|
163
|
-
const arr = objArray[key];
|
|
164
|
-
if (firstFields.includes(key)) {
|
|
165
|
-
asyncSerialArray(arr, func, next);
|
|
166
|
-
} else {
|
|
167
|
-
asyncParallelArray(arr, func, next);
|
|
168
|
-
}
|
|
169
|
-
});
|
|
170
|
-
});
|
|
171
|
-
pending.catch((error) => error.errors && error.fields || log.logger.error(error));
|
|
172
|
-
return pending;
|
|
173
|
-
}
|
|
174
|
-
function complementError(rule) {
|
|
175
|
-
return (onError) => {
|
|
176
|
-
if (onError && onError.message) {
|
|
177
|
-
onError.field = onError.field || rule.fullField;
|
|
178
|
-
return onError;
|
|
179
|
-
}
|
|
180
|
-
return {
|
|
181
|
-
message: typeof onError === "function" ? onError() : onError,
|
|
182
|
-
field: onError.field || rule.fullField
|
|
183
|
-
};
|
|
184
|
-
};
|
|
185
|
-
}
|
|
186
|
-
function deepMerge(target, sources) {
|
|
187
|
-
if (!sources) {
|
|
188
|
-
return target;
|
|
189
|
-
}
|
|
190
|
-
for (const source in sources) {
|
|
191
|
-
if (hasOwn.call(sources, source)) {
|
|
192
|
-
const value = sources[source];
|
|
193
|
-
if (typeof value === "object" && typeof target[source] === "object") {
|
|
194
|
-
target[source] = __spreadValues(__spreadValues({}, target[source]), value);
|
|
195
|
-
} else {
|
|
196
|
-
target[source] = value;
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
return target;
|
|
201
|
-
}
|
|
202
|
-
export {
|
|
203
|
-
asyncMap,
|
|
204
|
-
complementError,
|
|
205
|
-
convertFieldsError,
|
|
206
|
-
deepMerge,
|
|
207
|
-
format,
|
|
208
|
-
isEmptyObject,
|
|
209
|
-
isEmptyValue,
|
|
210
|
-
warning
|
|
211
|
-
};
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import "../../../chunk-G2ADBYYC.js";
|
|
2
|
-
import rules from "../rules/index";
|
|
3
|
-
import { isEmptyValue } from "../util";
|
|
4
|
-
import { hasOwn } from "../../type";
|
|
5
|
-
function array_default(rule, checkValue, callback, source, options) {
|
|
6
|
-
const errors = [];
|
|
7
|
-
const validate = rule.required || !rule.required && hasOwn.call(source, rule.field);
|
|
8
|
-
if (validate) {
|
|
9
|
-
if (isEmptyValue(checkValue, "array") && !rule.required) {
|
|
10
|
-
return callback();
|
|
11
|
-
}
|
|
12
|
-
rules.required({ rule, checkValue, source, errors, options, type: "array" });
|
|
13
|
-
if (!isEmptyValue(checkValue, "array")) {
|
|
14
|
-
rules.type(rule, checkValue, source, errors, options);
|
|
15
|
-
rules.range(rule, checkValue, source, errors, options);
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
callback(errors);
|
|
19
|
-
}
|
|
20
|
-
export {
|
|
21
|
-
array_default as default
|
|
22
|
-
};
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import "../../../chunk-G2ADBYYC.js";
|
|
2
|
-
import rules from "../rules/index";
|
|
3
|
-
import { isEmptyValue } from "../util";
|
|
4
|
-
import { hasOwn } from "../../type";
|
|
5
|
-
function date_default(rule, checkValue, callback, source, options) {
|
|
6
|
-
const errors = [];
|
|
7
|
-
const validate = rule.required || !rule.required && hasOwn.call(source, rule.field);
|
|
8
|
-
const isValidDateStr = (value) => value && typeof value === "string" && new Date(value).toString() !== "Invalid Date";
|
|
9
|
-
if (validate) {
|
|
10
|
-
if (isEmptyValue(checkValue) && !rule.required) {
|
|
11
|
-
return callback();
|
|
12
|
-
}
|
|
13
|
-
rules.required({ rule, checkValue, source, errors, options });
|
|
14
|
-
if (!isEmptyValue(checkValue)) {
|
|
15
|
-
let dateObject;
|
|
16
|
-
if (typeof checkValue === "number" || isValidDateStr(checkValue)) {
|
|
17
|
-
dateObject = new Date(checkValue);
|
|
18
|
-
} else {
|
|
19
|
-
dateObject = checkValue;
|
|
20
|
-
}
|
|
21
|
-
rules.type(rule, dateObject, source, errors, options);
|
|
22
|
-
if (dateObject && typeof dateObject.getTime === "function") {
|
|
23
|
-
rules.range(rule, dateObject.getTime(), source, errors, options);
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
callback(errors);
|
|
28
|
-
}
|
|
29
|
-
export {
|
|
30
|
-
date_default as default
|
|
31
|
-
};
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import "../../../chunk-G2ADBYYC.js";
|
|
2
|
-
import rules from "../rules/index";
|
|
3
|
-
import { isEmptyValue } from "../util";
|
|
4
|
-
import { hasOwn } from "../../type";
|
|
5
|
-
const ENUM = "enum";
|
|
6
|
-
function enum_default(rule, checkValue, callback, source, options) {
|
|
7
|
-
const errors = [];
|
|
8
|
-
const validate = rule.required || !rule.required && hasOwn.call(source, rule.field);
|
|
9
|
-
if (validate) {
|
|
10
|
-
if (isEmptyValue(checkValue) && !rule.required) {
|
|
11
|
-
return callback();
|
|
12
|
-
}
|
|
13
|
-
rules.required({ rule, checkValue, source, errors, options });
|
|
14
|
-
if (checkValue !== void 0) {
|
|
15
|
-
rules[ENUM](rule, checkValue, source, errors, options);
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
callback(errors);
|
|
19
|
-
}
|
|
20
|
-
export {
|
|
21
|
-
enum_default as default
|
|
22
|
-
};
|