@tachybase/schema 0.23.41 → 0.23.48
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/lib/core/effects/index.d.ts +2 -0
- package/lib/core/effects/index.js +23 -0
- package/lib/core/effects/onFieldEffects.d.ts +27 -0
- package/lib/core/effects/onFieldEffects.js +158 -0
- package/lib/core/effects/onFormEffects.d.ts +24 -0
- package/lib/core/effects/onFormEffects.js +117 -0
- package/lib/core/global.d.js +0 -0
- package/lib/core/index.d.ts +4 -0
- package/lib/core/index.js +27 -0
- package/lib/core/models/ArrayField.d.ts +17 -0
- package/lib/core/models/ArrayField.js +145 -0
- package/lib/core/models/BaseField.d.ts +72 -0
- package/lib/core/models/BaseField.js +285 -0
- package/lib/core/models/Field.d.ts +70 -0
- package/lib/core/models/Field.js +426 -0
- package/lib/core/models/Form.d.ts +102 -0
- package/lib/core/models/Form.js +483 -0
- package/lib/core/models/Graph.d.ts +8 -0
- package/lib/core/models/Graph.js +77 -0
- package/lib/core/models/Heart.d.ts +16 -0
- package/lib/core/models/Heart.js +91 -0
- package/lib/core/models/LifeCycle.d.ts +14 -0
- package/lib/core/models/LifeCycle.js +64 -0
- package/lib/core/models/ObjectField.d.ts +12 -0
- package/lib/core/models/ObjectField.js +64 -0
- package/lib/core/models/Query.d.ts +18 -0
- package/lib/core/models/Query.js +105 -0
- package/lib/core/models/VoidField.d.ts +14 -0
- package/lib/core/models/VoidField.js +117 -0
- package/lib/core/models/index.d.ts +9 -0
- package/lib/core/models/index.js +37 -0
- package/lib/core/models/types.d.ts +9 -0
- package/lib/core/models/types.js +15 -0
- package/lib/core/shared/checkers.d.ts +117 -0
- package/lib/core/shared/checkers.js +109 -0
- package/lib/core/shared/constants.d.ts +48 -0
- package/lib/core/shared/constants.js +86 -0
- package/lib/core/shared/effective.d.ts +9 -0
- package/lib/core/shared/effective.js +91 -0
- package/lib/core/shared/externals.d.ts +8 -0
- package/lib/core/shared/externals.js +87 -0
- package/lib/core/shared/internals.d.ts +54 -0
- package/lib/core/shared/internals.js +956 -0
- package/lib/core/types.d.ts +275 -0
- package/lib/core/types.js +76 -0
- package/lib/grid/index.d.ts +67 -0
- package/lib/grid/index.js +378 -0
- package/lib/grid/observer.d.ts +19 -0
- package/lib/grid/observer.js +107 -0
- package/lib/index.d.ts +12 -24
- package/lib/index.js +27 -244
- package/lib/json-schema/compiler.d.ts +8 -0
- package/lib/json-schema/compiler.js +129 -0
- package/lib/json-schema/global.d.js +0 -0
- package/lib/json-schema/index.d.ts +2 -0
- package/lib/json-schema/index.js +23 -0
- package/lib/json-schema/patches.d.ts +5 -0
- package/lib/json-schema/patches.js +68 -0
- package/lib/json-schema/polyfills/SPECIFICATION_1_0.d.ts +2 -0
- package/lib/json-schema/polyfills/SPECIFICATION_1_0.js +132 -0
- package/lib/json-schema/polyfills/index.d.ts +1 -0
- package/lib/json-schema/polyfills/index.js +21 -0
- package/lib/json-schema/schema.d.ts +88 -0
- package/lib/json-schema/schema.js +231 -0
- package/lib/json-schema/shared.d.ts +62 -0
- package/lib/json-schema/shared.js +232 -0
- package/lib/json-schema/transformer.d.ts +4 -0
- package/lib/json-schema/transformer.js +238 -0
- package/lib/json-schema/types.d.ts +119 -0
- package/lib/json-schema/types.js +15 -0
- package/lib/path/contexts.d.ts +10 -0
- package/lib/path/contexts.js +49 -0
- package/lib/path/destructor.d.ts +15 -0
- package/lib/path/destructor.js +151 -0
- package/lib/path/index.d.ts +51 -0
- package/lib/path/index.js +513 -0
- package/lib/path/matcher.d.ts +33 -0
- package/lib/path/matcher.js +197 -0
- package/lib/path/parser.d.ts +33 -0
- package/lib/path/parser.js +379 -0
- package/lib/path/shared.d.ts +13 -0
- package/lib/path/shared.js +121 -0
- package/lib/path/tokenizer.d.ts +27 -0
- package/lib/path/tokenizer.js +269 -0
- package/lib/path/tokens.d.ts +27 -0
- package/lib/path/tokens.js +216 -0
- package/lib/path/types.d.ts +88 -0
- package/lib/path/types.js +63 -0
- package/lib/react/components/ArrayField.d.ts +6 -0
- package/lib/react/components/ArrayField.js +44 -0
- package/lib/react/components/ExpressionScope.d.ts +2 -0
- package/lib/react/components/ExpressionScope.js +35 -0
- package/lib/react/components/Field.d.ts +5 -0
- package/lib/react/components/Field.js +45 -0
- package/lib/react/components/FormConsumer.d.ts +2 -0
- package/lib/react/components/FormConsumer.js +36 -0
- package/lib/react/components/FormProvider.d.ts +2 -0
- package/lib/react/components/FormProvider.js +35 -0
- package/lib/react/components/ObjectField.d.ts +6 -0
- package/lib/react/components/ObjectField.js +39 -0
- package/lib/react/components/ReactiveField.d.ts +11 -0
- package/lib/react/components/ReactiveField.js +115 -0
- package/lib/react/components/RecordScope.d.ts +2 -0
- package/lib/react/components/RecordScope.js +65 -0
- package/lib/react/components/RecordsScope.d.ts +2 -0
- package/lib/react/components/RecordsScope.js +43 -0
- package/lib/react/components/RecursionField.d.ts +2 -0
- package/lib/react/components/RecursionField.js +105 -0
- package/lib/react/components/SchemaField.d.ts +41 -0
- package/lib/react/components/SchemaField.js +154 -0
- package/lib/react/components/VoidField.d.ts +5 -0
- package/lib/react/components/VoidField.js +39 -0
- package/lib/react/components/index.d.ts +11 -0
- package/lib/react/components/index.js +41 -0
- package/lib/react/global.d.js +0 -0
- package/lib/react/hooks/index.d.ts +6 -0
- package/lib/react/hooks/index.js +31 -0
- package/lib/react/hooks/useAttach.d.ts +6 -0
- package/lib/react/hooks/useAttach.js +35 -0
- package/lib/react/hooks/useExpressionScope.d.ts +1 -0
- package/lib/react/hooks/useExpressionScope.js +30 -0
- package/lib/react/hooks/useField.d.ts +2 -0
- package/lib/react/hooks/useField.js +32 -0
- package/lib/react/hooks/useFieldSchema.d.ts +2 -0
- package/lib/react/hooks/useFieldSchema.js +32 -0
- package/lib/react/hooks/useForm.d.ts +2 -0
- package/lib/react/hooks/useForm.js +32 -0
- package/lib/react/hooks/useFormEffects.d.ts +2 -0
- package/lib/react/hooks/useFormEffects.js +42 -0
- package/lib/react/hooks/useParentForm.d.ts +2 -0
- package/lib/react/hooks/useParentForm.js +40 -0
- package/lib/react/index.d.ts +5 -0
- package/lib/react/index.js +29 -0
- package/lib/react/shared/connect.d.ts +9 -0
- package/lib/react/shared/connect.js +118 -0
- package/lib/react/shared/context.d.ts +14 -0
- package/lib/react/shared/context.js +74 -0
- package/lib/react/shared/index.d.ts +2 -0
- package/lib/react/shared/index.js +23 -0
- package/lib/react/shared/render.d.ts +2 -0
- package/lib/react/shared/render.js +69 -0
- package/lib/react/types.d.ts +84 -0
- package/lib/react/types.js +15 -0
- package/lib/reactive/action.d.ts +2 -0
- package/lib/reactive/action.js +48 -0
- package/lib/reactive/annotations/box.d.ts +7 -0
- package/lib/reactive/annotations/box.js +76 -0
- package/lib/reactive/annotations/computed.d.ts +12 -0
- package/lib/reactive/annotations/computed.js +154 -0
- package/lib/reactive/annotations/index.d.ts +5 -0
- package/lib/reactive/annotations/index.js +29 -0
- package/lib/reactive/annotations/observable.d.ts +4 -0
- package/lib/reactive/annotations/observable.js +67 -0
- package/lib/reactive/annotations/ref.d.ts +6 -0
- package/lib/reactive/annotations/ref.js +78 -0
- package/lib/reactive/annotations/shallow.d.ts +2 -0
- package/lib/reactive/annotations/shallow.js +67 -0
- package/lib/reactive/array.d.ts +12 -0
- package/lib/reactive/array.js +83 -0
- package/lib/reactive/autorun.d.ts +7 -0
- package/lib/reactive/autorun.js +155 -0
- package/lib/reactive/batch.d.ts +2 -0
- package/lib/reactive/batch.js +40 -0
- package/lib/reactive/checkers.d.ts +10 -0
- package/lib/reactive/checkers.js +60 -0
- package/lib/reactive/environment.d.ts +28 -0
- package/lib/reactive/environment.js +76 -0
- package/lib/reactive/externals.d.ts +10 -0
- package/lib/reactive/externals.js +156 -0
- package/lib/reactive/global.d.js +0 -0
- package/lib/reactive/handlers.d.ts +4 -0
- package/lib/reactive/handlers.js +246 -0
- package/lib/reactive/index.d.ts +10 -0
- package/lib/reactive/index.js +39 -0
- package/lib/reactive/internals.d.ts +17 -0
- package/lib/reactive/internals.js +139 -0
- package/lib/reactive/model.d.ts +3 -0
- package/lib/reactive/model.js +68 -0
- package/lib/reactive/observable.d.ts +9 -0
- package/lib/reactive/observable.js +50 -0
- package/lib/reactive/observe.d.ts +2 -0
- package/lib/reactive/observe.js +58 -0
- package/lib/reactive/reaction.d.ts +21 -0
- package/lib/reactive/reaction.js +278 -0
- package/lib/reactive/tracker.d.ts +7 -0
- package/lib/reactive/tracker.js +63 -0
- package/lib/reactive/tree.d.ts +25 -0
- package/lib/reactive/tree.js +106 -0
- package/lib/reactive/types.d.ts +79 -0
- package/lib/reactive/types.js +21 -0
- package/lib/reactive/untracked.d.ts +4 -0
- package/lib/reactive/untracked.js +29 -0
- package/lib/reactive-react/hooks/index.d.ts +9 -0
- package/lib/reactive-react/hooks/index.js +48 -0
- package/lib/reactive-react/hooks/useCompatEffect.d.ts +2 -0
- package/lib/reactive-react/hooks/useCompatEffect.js +60 -0
- package/lib/reactive-react/hooks/useCompatFactory.d.ts +3 -0
- package/lib/reactive-react/hooks/useCompatFactory.js +74 -0
- package/lib/reactive-react/hooks/useDidUpdate.d.ts +1 -0
- package/lib/reactive-react/hooks/useDidUpdate.js +38 -0
- package/lib/reactive-react/hooks/useForceUpdate.d.ts +1 -0
- package/lib/reactive-react/hooks/useForceUpdate.js +76 -0
- package/lib/reactive-react/hooks/useLayoutEffect.d.ts +2 -0
- package/lib/reactive-react/hooks/useLayoutEffect.js +28 -0
- package/lib/reactive-react/hooks/useObserver.d.ts +2 -0
- package/lib/reactive-react/hooks/useObserver.js +43 -0
- package/lib/reactive-react/index.d.ts +3 -0
- package/lib/reactive-react/index.js +25 -0
- package/lib/reactive-react/observer.d.ts +8 -0
- package/lib/reactive-react/observer.js +64 -0
- package/lib/reactive-react/shared/gc.d.ts +8 -0
- package/lib/reactive-react/shared/gc.js +59 -0
- package/lib/reactive-react/shared/global.d.ts +1 -0
- package/lib/reactive-react/shared/global.js +50 -0
- package/lib/reactive-react/shared/immediate.d.ts +1 -0
- package/lib/reactive-react/shared/immediate.js +40 -0
- package/lib/reactive-react/shared/index.d.ts +2 -0
- package/lib/reactive-react/shared/index.js +23 -0
- package/lib/reactive-react/types.d.ts +14 -0
- package/lib/reactive-react/types.js +15 -0
- package/lib/shared/array.d.ts +35 -0
- package/lib/shared/array.js +189 -0
- package/lib/shared/case.d.ts +6 -0
- package/lib/shared/case.js +39 -0
- package/lib/shared/checkers.d.ts +21 -0
- package/lib/shared/checkers.js +77 -0
- package/lib/shared/clone.d.ts +2 -0
- package/lib/shared/clone.js +97 -0
- package/lib/shared/compare.d.ts +1 -0
- package/lib/shared/compare.js +129 -0
- package/lib/shared/defaults.d.ts +6 -0
- package/lib/shared/defaults.js +63 -0
- package/lib/shared/deprecate.d.ts +1 -0
- package/lib/shared/deprecate.js +42 -0
- package/lib/shared/global.d.ts +1 -0
- package/lib/shared/global.js +50 -0
- package/lib/shared/index.d.ts +16 -0
- package/lib/shared/index.js +51 -0
- package/lib/shared/instanceof.d.ts +1 -0
- package/lib/shared/instanceof.js +36 -0
- package/lib/shared/isEmpty.d.ts +3 -0
- package/lib/shared/isEmpty.js +94 -0
- package/lib/shared/merge.d.ts +12 -0
- package/lib/shared/merge.js +214 -0
- package/lib/shared/middleware.d.ts +4 -0
- package/lib/shared/middleware.js +41 -0
- package/lib/shared/path.d.ts +3 -0
- package/lib/shared/path.js +27 -0
- package/lib/shared/string.d.ts +1 -0
- package/lib/shared/string.js +38 -0
- package/lib/shared/subscribable.d.ts +11 -0
- package/lib/shared/subscribable.js +74 -0
- package/lib/shared/uid.d.ts +1 -0
- package/lib/shared/uid.js +35 -0
- package/lib/validator/formats.d.ts +16 -0
- package/lib/validator/formats.js +40 -0
- package/lib/validator/index.d.ts +4 -0
- package/lib/validator/index.js +27 -0
- package/lib/validator/locale.d.ts +219 -0
- package/lib/validator/locale.js +240 -0
- package/lib/validator/parser.d.ts +5 -0
- package/lib/validator/parser.js +153 -0
- package/lib/validator/registry.d.ts +15 -0
- package/lib/validator/registry.js +116 -0
- package/lib/validator/rules.d.ts +3 -0
- package/lib/validator/rules.js +154 -0
- package/lib/validator/template.d.ts +2 -0
- package/lib/validator/template.js +42 -0
- package/lib/validator/types.d.ts +62 -0
- package/lib/validator/types.js +28 -0
- package/lib/validator/validator.d.ts +2 -0
- package/lib/validator/validator.js +63 -0
- package/package.json +16 -10
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var rules_exports = {};
|
|
20
|
+
__export(rules_exports, {
|
|
21
|
+
default: () => rules_default
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(rules_exports);
|
|
24
|
+
var import_shared = require("../shared");
|
|
25
|
+
var import_registry = require("./registry");
|
|
26
|
+
const isValidateEmpty = /* @__PURE__ */ __name((value) => {
|
|
27
|
+
var _a;
|
|
28
|
+
if ((0, import_shared.isArr)(value)) {
|
|
29
|
+
for (let i = 0; i < value.length; i++) {
|
|
30
|
+
if ((0, import_shared.isValid)(value[i])) return false;
|
|
31
|
+
}
|
|
32
|
+
return true;
|
|
33
|
+
} else {
|
|
34
|
+
if (value == null ? void 0 : value.getCurrentContent) {
|
|
35
|
+
return !((_a = value.getCurrentContent()) == null ? void 0 : _a.hasText());
|
|
36
|
+
}
|
|
37
|
+
return (0, import_shared.isEmpty)(value);
|
|
38
|
+
}
|
|
39
|
+
}, "isValidateEmpty");
|
|
40
|
+
const getLength = /* @__PURE__ */ __name((value) => (0, import_shared.isStr)(value) ? (0, import_shared.stringLength)(value) : value ? value.length : 0, "getLength");
|
|
41
|
+
const extendSameRules = /* @__PURE__ */ __name((rules, names) => {
|
|
42
|
+
(0, import_shared.each)(names, (realName, name) => {
|
|
43
|
+
rules[name] = (value, rule, ...args) => rules[realName](value, { ...rule, [realName]: rule[name] }, ...args);
|
|
44
|
+
});
|
|
45
|
+
}, "extendSameRules");
|
|
46
|
+
const RULES = {
|
|
47
|
+
format(value, rule) {
|
|
48
|
+
if (isValidateEmpty(value)) return "";
|
|
49
|
+
if (rule.format) {
|
|
50
|
+
const format = (0, import_registry.getValidateFormats)(rule.format);
|
|
51
|
+
if (format) {
|
|
52
|
+
return !new RegExp(format).test(value) ? rule.message : "";
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
return "";
|
|
56
|
+
},
|
|
57
|
+
required(value, rule) {
|
|
58
|
+
if (rule.required === false) return "";
|
|
59
|
+
return isValidateEmpty(value) ? rule.message : "";
|
|
60
|
+
},
|
|
61
|
+
max(value, rule) {
|
|
62
|
+
if (isValidateEmpty(value)) return "";
|
|
63
|
+
const length = (0, import_shared.isNum)(value) ? value : getLength(value);
|
|
64
|
+
const max = Number(rule.max);
|
|
65
|
+
return length > max ? rule.message : "";
|
|
66
|
+
},
|
|
67
|
+
min(value, rule) {
|
|
68
|
+
if (isValidateEmpty(value)) return "";
|
|
69
|
+
const length = (0, import_shared.isNum)(value) ? value : getLength(value);
|
|
70
|
+
const min = Number(rule.min);
|
|
71
|
+
return length < min ? rule.message : "";
|
|
72
|
+
},
|
|
73
|
+
exclusiveMaximum(value, rule) {
|
|
74
|
+
if (isValidateEmpty(value)) return "";
|
|
75
|
+
const length = (0, import_shared.isNum)(value) ? value : getLength(value);
|
|
76
|
+
const max = Number(rule.exclusiveMaximum);
|
|
77
|
+
return length >= max ? rule.message : "";
|
|
78
|
+
},
|
|
79
|
+
exclusiveMinimum(value, rule) {
|
|
80
|
+
if (isValidateEmpty(value)) return "";
|
|
81
|
+
const length = (0, import_shared.isNum)(value) ? value : getLength(value);
|
|
82
|
+
const min = Number(rule.exclusiveMinimum);
|
|
83
|
+
return length <= min ? rule.message : "";
|
|
84
|
+
},
|
|
85
|
+
len(value, rule) {
|
|
86
|
+
if (isValidateEmpty(value)) return "";
|
|
87
|
+
const length = getLength(value);
|
|
88
|
+
const len = Number(rule.len);
|
|
89
|
+
return length !== len ? rule.message : "";
|
|
90
|
+
},
|
|
91
|
+
pattern(value, rule) {
|
|
92
|
+
if (isValidateEmpty(value)) return "";
|
|
93
|
+
return !new RegExp(rule.pattern).test(value) ? rule.message : "";
|
|
94
|
+
},
|
|
95
|
+
async validator(value, rule, context, format) {
|
|
96
|
+
if ((0, import_shared.isFn)(rule.validator)) {
|
|
97
|
+
const response = await Promise.resolve(rule.validator(value, rule, context, format));
|
|
98
|
+
if ((0, import_shared.isBool)(response)) {
|
|
99
|
+
return !response ? rule.message : "";
|
|
100
|
+
} else {
|
|
101
|
+
return response;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
throw new Error("The rule's validator property must be a function.");
|
|
105
|
+
},
|
|
106
|
+
whitespace(value, rule) {
|
|
107
|
+
if (isValidateEmpty(value)) return "";
|
|
108
|
+
if (rule.whitespace) {
|
|
109
|
+
return /^\s+$/.test(value) ? rule.message : "";
|
|
110
|
+
}
|
|
111
|
+
},
|
|
112
|
+
enum(value, rule) {
|
|
113
|
+
if (isValidateEmpty(value)) return "";
|
|
114
|
+
const enums = (0, import_shared.toArr)(rule.enum);
|
|
115
|
+
return enums.indexOf(value) === -1 ? rule.message : "";
|
|
116
|
+
},
|
|
117
|
+
const(value, rule) {
|
|
118
|
+
if (isValidateEmpty(value)) return "";
|
|
119
|
+
return rule.const !== value ? rule.message : "";
|
|
120
|
+
},
|
|
121
|
+
multipleOf(value, rule) {
|
|
122
|
+
if (isValidateEmpty(value)) return "";
|
|
123
|
+
return Number(value) % Number(rule.multipleOf) !== 0 ? rule.message : "";
|
|
124
|
+
},
|
|
125
|
+
uniqueItems(value, rule) {
|
|
126
|
+
if (isValidateEmpty(value)) return "";
|
|
127
|
+
value = (0, import_shared.toArr)(value);
|
|
128
|
+
return value.some((item, index) => {
|
|
129
|
+
for (let i = 0; i < value.length; i++) {
|
|
130
|
+
if (i !== index && !(0, import_shared.isEqual)(value[i], item)) {
|
|
131
|
+
return false;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
return true;
|
|
135
|
+
}) ? "" : rule.message;
|
|
136
|
+
},
|
|
137
|
+
maxProperties(value, rule) {
|
|
138
|
+
if (isValidateEmpty(value)) return "";
|
|
139
|
+
return Object.keys(value || {}).length <= Number(rule.maxProperties) ? "" : rule.message;
|
|
140
|
+
},
|
|
141
|
+
minProperties(value, rule) {
|
|
142
|
+
if (isValidateEmpty(value)) return "";
|
|
143
|
+
return Object.keys(value || {}).length >= Number(rule.minProperties) ? "" : rule.message;
|
|
144
|
+
}
|
|
145
|
+
};
|
|
146
|
+
extendSameRules(RULES, {
|
|
147
|
+
maximum: "max",
|
|
148
|
+
minimum: "min",
|
|
149
|
+
maxItems: "max",
|
|
150
|
+
minItems: "min",
|
|
151
|
+
maxLength: "max",
|
|
152
|
+
minLength: "min"
|
|
153
|
+
});
|
|
154
|
+
var rules_default = RULES;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var template_exports = {};
|
|
20
|
+
__export(template_exports, {
|
|
21
|
+
render: () => render
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(template_exports);
|
|
24
|
+
var import_shared = require("../shared");
|
|
25
|
+
var import_registry = require("./registry");
|
|
26
|
+
const render = /* @__PURE__ */ __name((result, rules) => {
|
|
27
|
+
const { message } = result;
|
|
28
|
+
if ((0, import_shared.isStr)(message)) {
|
|
29
|
+
const template = (0, import_registry.getValidateMessageTemplateEngine)();
|
|
30
|
+
if ((0, import_shared.isFn)(template)) {
|
|
31
|
+
result.message = template(message, rules);
|
|
32
|
+
}
|
|
33
|
+
result.message = result.message.replace(/\{\{\s*([\w.]+)\s*\}\}/g, (_, $0) => {
|
|
34
|
+
return import_shared.FormPath.getIn(rules, $0);
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
return result;
|
|
38
|
+
}, "render");
|
|
39
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
40
|
+
0 && (module.exports = {
|
|
41
|
+
render
|
|
42
|
+
});
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
export type ValidatorFormats = 'url' | 'email' | 'ipv6' | 'ipv4' | 'number' | 'integer' | 'idcard' | 'qq' | 'phone' | 'money' | 'zh' | 'date' | 'zip' | (string & {});
|
|
2
|
+
export interface IValidateResult {
|
|
3
|
+
type: 'error' | 'warning' | 'success' | (string & {});
|
|
4
|
+
message: string;
|
|
5
|
+
}
|
|
6
|
+
export interface IValidateResults {
|
|
7
|
+
error?: string[];
|
|
8
|
+
warning?: string[];
|
|
9
|
+
success?: string[];
|
|
10
|
+
}
|
|
11
|
+
export declare const isValidateResult: (obj: any) => obj is IValidateResult;
|
|
12
|
+
export type ValidatorFunctionResponse = null | string | boolean | IValidateResult;
|
|
13
|
+
export type ValidatorFunction<Context = any> = (value: any, rule: IValidatorRules<Context>, ctx: Context, render: (message: string, scope?: any) => string) => ValidatorFunctionResponse | Promise<ValidatorFunctionResponse> | null;
|
|
14
|
+
export type ValidatorParsedFunction<Context = any> = (value: any, ctx: Context) => IValidateResult | Promise<IValidateResult> | null;
|
|
15
|
+
export type ValidatorTriggerType = 'onInput' | 'onFocus' | 'onBlur' | (string & {});
|
|
16
|
+
export interface IValidatorRules<Context = any> {
|
|
17
|
+
triggerType?: ValidatorTriggerType;
|
|
18
|
+
format?: ValidatorFormats;
|
|
19
|
+
validator?: ValidatorFunction<Context>;
|
|
20
|
+
required?: boolean;
|
|
21
|
+
pattern?: RegExp | string;
|
|
22
|
+
max?: number;
|
|
23
|
+
maximum?: number;
|
|
24
|
+
maxItems?: number;
|
|
25
|
+
minItems?: number;
|
|
26
|
+
maxLength?: number;
|
|
27
|
+
minLength?: number;
|
|
28
|
+
exclusiveMaximum?: number;
|
|
29
|
+
exclusiveMinimum?: number;
|
|
30
|
+
minimum?: number;
|
|
31
|
+
min?: number;
|
|
32
|
+
len?: number;
|
|
33
|
+
whitespace?: boolean;
|
|
34
|
+
enum?: any[];
|
|
35
|
+
const?: any;
|
|
36
|
+
multipleOf?: number;
|
|
37
|
+
uniqueItems?: boolean;
|
|
38
|
+
maxProperties?: number;
|
|
39
|
+
minProperties?: number;
|
|
40
|
+
message?: string;
|
|
41
|
+
[key: string]: any;
|
|
42
|
+
}
|
|
43
|
+
export interface IRegistryLocaleMessages {
|
|
44
|
+
[key: string]: string | IRegistryLocaleMessages;
|
|
45
|
+
}
|
|
46
|
+
export interface IRegistryLocales {
|
|
47
|
+
[language: string]: IRegistryLocaleMessages;
|
|
48
|
+
}
|
|
49
|
+
export interface IRegistryRules<Context = any> {
|
|
50
|
+
[key: string]: ValidatorFunction<Context>;
|
|
51
|
+
}
|
|
52
|
+
export interface IRegistryFormats {
|
|
53
|
+
[key: string]: string | RegExp;
|
|
54
|
+
}
|
|
55
|
+
export type ValidatorDescription<Context = any> = ValidatorFormats | ValidatorFunction<Context> | IValidatorRules<Context>;
|
|
56
|
+
export type MultiValidator<Context = any> = ValidatorDescription<Context>[];
|
|
57
|
+
export type Validator<Context = any> = ValidatorDescription<Context> | MultiValidator<Context>;
|
|
58
|
+
export interface IValidatorOptions<Context = any> {
|
|
59
|
+
validateFirst?: boolean;
|
|
60
|
+
triggerType?: ValidatorTriggerType;
|
|
61
|
+
context?: Context;
|
|
62
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var types_exports = {};
|
|
20
|
+
__export(types_exports, {
|
|
21
|
+
isValidateResult: () => isValidateResult
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(types_exports);
|
|
24
|
+
const isValidateResult = /* @__PURE__ */ __name((obj) => !!obj["type"] && !!obj["message"], "isValidateResult");
|
|
25
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
26
|
+
0 && (module.exports = {
|
|
27
|
+
isValidateResult
|
|
28
|
+
});
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var validator_exports = {};
|
|
30
|
+
__export(validator_exports, {
|
|
31
|
+
validate: () => validate
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(validator_exports);
|
|
34
|
+
var import_formats = __toESM(require("./formats"));
|
|
35
|
+
var import_locale = __toESM(require("./locale"));
|
|
36
|
+
var import_parser = require("./parser");
|
|
37
|
+
var import_registry = require("./registry");
|
|
38
|
+
var import_rules = __toESM(require("./rules"));
|
|
39
|
+
(0, import_registry.registerValidateRules)(import_rules.default);
|
|
40
|
+
(0, import_registry.registerValidateLocale)(import_locale.default);
|
|
41
|
+
(0, import_registry.registerValidateFormats)(import_formats.default);
|
|
42
|
+
const validate = /* @__PURE__ */ __name(async (value, validator, options) => {
|
|
43
|
+
const validates = (0, import_parser.parseValidator)(validator, options);
|
|
44
|
+
const results = {
|
|
45
|
+
error: [],
|
|
46
|
+
success: [],
|
|
47
|
+
warning: []
|
|
48
|
+
};
|
|
49
|
+
for (let i = 0; i < validates.length; i++) {
|
|
50
|
+
const result = await validates[i](value, options == null ? void 0 : options.context);
|
|
51
|
+
const { type, message } = result;
|
|
52
|
+
results[type] = results[type] || [];
|
|
53
|
+
if (message) {
|
|
54
|
+
results[type].push(message);
|
|
55
|
+
if (options == null ? void 0 : options.validateFirst) break;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
return results;
|
|
59
|
+
}, "validate");
|
|
60
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
61
|
+
0 && (module.exports = {
|
|
62
|
+
validate
|
|
63
|
+
});
|
package/package.json
CHANGED
|
@@ -1,19 +1,25 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tachybase/schema",
|
|
3
|
-
"version": "0.23.
|
|
3
|
+
"version": "0.23.48",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "lib/index.d.ts",
|
|
7
7
|
"dependencies": {
|
|
8
|
-
"
|
|
9
|
-
"
|
|
10
|
-
"
|
|
11
|
-
"
|
|
12
|
-
"
|
|
13
|
-
"
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
"@
|
|
8
|
+
"camel-case": "^4.1.1",
|
|
9
|
+
"hoist-non-react-statics": "^3.3.2",
|
|
10
|
+
"lower-case": "^2.0.1",
|
|
11
|
+
"param-case": "^3.0.4",
|
|
12
|
+
"pascal-case": "^3.1.1",
|
|
13
|
+
"upper-case": "^2.0.1"
|
|
14
|
+
},
|
|
15
|
+
"devDependencies": {
|
|
16
|
+
"@testing-library/react": "16.2.0",
|
|
17
|
+
"immutable": "5.0.3",
|
|
18
|
+
"moment": "2.30.1",
|
|
19
|
+
"vitest": "3.0.5"
|
|
20
|
+
},
|
|
21
|
+
"peerDependencies": {
|
|
22
|
+
"react": ">=16.8.0"
|
|
17
23
|
},
|
|
18
24
|
"scripts": {
|
|
19
25
|
"build": "tachybase-build --no-dts @tachybase/schema"
|