@tachybase/schema 0.23.41 → 0.23.47

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 (273) hide show
  1. package/lib/core/effects/index.d.ts +2 -0
  2. package/lib/core/effects/index.js +23 -0
  3. package/lib/core/effects/onFieldEffects.d.ts +27 -0
  4. package/lib/core/effects/onFieldEffects.js +158 -0
  5. package/lib/core/effects/onFormEffects.d.ts +24 -0
  6. package/lib/core/effects/onFormEffects.js +117 -0
  7. package/lib/core/global.d.js +0 -0
  8. package/lib/core/index.d.ts +4 -0
  9. package/lib/core/index.js +27 -0
  10. package/lib/core/models/ArrayField.d.ts +17 -0
  11. package/lib/core/models/ArrayField.js +145 -0
  12. package/lib/core/models/BaseField.d.ts +72 -0
  13. package/lib/core/models/BaseField.js +285 -0
  14. package/lib/core/models/Field.d.ts +70 -0
  15. package/lib/core/models/Field.js +426 -0
  16. package/lib/core/models/Form.d.ts +102 -0
  17. package/lib/core/models/Form.js +483 -0
  18. package/lib/core/models/Graph.d.ts +8 -0
  19. package/lib/core/models/Graph.js +77 -0
  20. package/lib/core/models/Heart.d.ts +16 -0
  21. package/lib/core/models/Heart.js +91 -0
  22. package/lib/core/models/LifeCycle.d.ts +14 -0
  23. package/lib/core/models/LifeCycle.js +64 -0
  24. package/lib/core/models/ObjectField.d.ts +12 -0
  25. package/lib/core/models/ObjectField.js +64 -0
  26. package/lib/core/models/Query.d.ts +18 -0
  27. package/lib/core/models/Query.js +105 -0
  28. package/lib/core/models/VoidField.d.ts +14 -0
  29. package/lib/core/models/VoidField.js +117 -0
  30. package/lib/core/models/index.d.ts +9 -0
  31. package/lib/core/models/index.js +37 -0
  32. package/lib/core/models/types.d.ts +9 -0
  33. package/lib/core/models/types.js +15 -0
  34. package/lib/core/shared/checkers.d.ts +117 -0
  35. package/lib/core/shared/checkers.js +109 -0
  36. package/lib/core/shared/constants.d.ts +48 -0
  37. package/lib/core/shared/constants.js +86 -0
  38. package/lib/core/shared/effective.d.ts +9 -0
  39. package/lib/core/shared/effective.js +91 -0
  40. package/lib/core/shared/externals.d.ts +8 -0
  41. package/lib/core/shared/externals.js +87 -0
  42. package/lib/core/shared/internals.d.ts +54 -0
  43. package/lib/core/shared/internals.js +956 -0
  44. package/lib/core/types.d.ts +275 -0
  45. package/lib/core/types.js +76 -0
  46. package/lib/grid/index.d.ts +67 -0
  47. package/lib/grid/index.js +378 -0
  48. package/lib/grid/observer.d.ts +19 -0
  49. package/lib/grid/observer.js +107 -0
  50. package/lib/index.d.ts +12 -24
  51. package/lib/index.js +27 -244
  52. package/lib/json-schema/compiler.d.ts +8 -0
  53. package/lib/json-schema/compiler.js +129 -0
  54. package/lib/json-schema/global.d.js +0 -0
  55. package/lib/json-schema/index.d.ts +2 -0
  56. package/lib/json-schema/index.js +23 -0
  57. package/lib/json-schema/patches.d.ts +5 -0
  58. package/lib/json-schema/patches.js +68 -0
  59. package/lib/json-schema/polyfills/SPECIFICATION_1_0.d.ts +2 -0
  60. package/lib/json-schema/polyfills/SPECIFICATION_1_0.js +132 -0
  61. package/lib/json-schema/polyfills/index.d.ts +1 -0
  62. package/lib/json-schema/polyfills/index.js +21 -0
  63. package/lib/json-schema/schema.d.ts +88 -0
  64. package/lib/json-schema/schema.js +231 -0
  65. package/lib/json-schema/shared.d.ts +62 -0
  66. package/lib/json-schema/shared.js +232 -0
  67. package/lib/json-schema/transformer.d.ts +4 -0
  68. package/lib/json-schema/transformer.js +238 -0
  69. package/lib/json-schema/types.d.ts +119 -0
  70. package/lib/json-schema/types.js +15 -0
  71. package/lib/path/contexts.d.ts +10 -0
  72. package/lib/path/contexts.js +49 -0
  73. package/lib/path/destructor.d.ts +15 -0
  74. package/lib/path/destructor.js +151 -0
  75. package/lib/path/index.d.ts +51 -0
  76. package/lib/path/index.js +513 -0
  77. package/lib/path/matcher.d.ts +33 -0
  78. package/lib/path/matcher.js +197 -0
  79. package/lib/path/parser.d.ts +33 -0
  80. package/lib/path/parser.js +379 -0
  81. package/lib/path/shared.d.ts +13 -0
  82. package/lib/path/shared.js +121 -0
  83. package/lib/path/tokenizer.d.ts +27 -0
  84. package/lib/path/tokenizer.js +269 -0
  85. package/lib/path/tokens.d.ts +27 -0
  86. package/lib/path/tokens.js +216 -0
  87. package/lib/path/types.d.ts +88 -0
  88. package/lib/path/types.js +63 -0
  89. package/lib/react/components/ArrayField.d.ts +6 -0
  90. package/lib/react/components/ArrayField.js +44 -0
  91. package/lib/react/components/ExpressionScope.d.ts +2 -0
  92. package/lib/react/components/ExpressionScope.js +35 -0
  93. package/lib/react/components/Field.d.ts +5 -0
  94. package/lib/react/components/Field.js +45 -0
  95. package/lib/react/components/FormConsumer.d.ts +2 -0
  96. package/lib/react/components/FormConsumer.js +36 -0
  97. package/lib/react/components/FormProvider.d.ts +2 -0
  98. package/lib/react/components/FormProvider.js +35 -0
  99. package/lib/react/components/ObjectField.d.ts +6 -0
  100. package/lib/react/components/ObjectField.js +39 -0
  101. package/lib/react/components/ReactiveField.d.ts +11 -0
  102. package/lib/react/components/ReactiveField.js +115 -0
  103. package/lib/react/components/RecordScope.d.ts +2 -0
  104. package/lib/react/components/RecordScope.js +65 -0
  105. package/lib/react/components/RecordsScope.d.ts +2 -0
  106. package/lib/react/components/RecordsScope.js +43 -0
  107. package/lib/react/components/RecursionField.d.ts +2 -0
  108. package/lib/react/components/RecursionField.js +105 -0
  109. package/lib/react/components/SchemaField.d.ts +41 -0
  110. package/lib/react/components/SchemaField.js +154 -0
  111. package/lib/react/components/VoidField.d.ts +5 -0
  112. package/lib/react/components/VoidField.js +39 -0
  113. package/lib/react/components/index.d.ts +11 -0
  114. package/lib/react/components/index.js +41 -0
  115. package/lib/react/global.d.js +0 -0
  116. package/lib/react/hooks/index.d.ts +6 -0
  117. package/lib/react/hooks/index.js +31 -0
  118. package/lib/react/hooks/useAttach.d.ts +6 -0
  119. package/lib/react/hooks/useAttach.js +35 -0
  120. package/lib/react/hooks/useExpressionScope.d.ts +1 -0
  121. package/lib/react/hooks/useExpressionScope.js +30 -0
  122. package/lib/react/hooks/useField.d.ts +2 -0
  123. package/lib/react/hooks/useField.js +32 -0
  124. package/lib/react/hooks/useFieldSchema.d.ts +2 -0
  125. package/lib/react/hooks/useFieldSchema.js +32 -0
  126. package/lib/react/hooks/useForm.d.ts +2 -0
  127. package/lib/react/hooks/useForm.js +32 -0
  128. package/lib/react/hooks/useFormEffects.d.ts +2 -0
  129. package/lib/react/hooks/useFormEffects.js +42 -0
  130. package/lib/react/hooks/useParentForm.d.ts +2 -0
  131. package/lib/react/hooks/useParentForm.js +40 -0
  132. package/lib/react/index.d.ts +5 -0
  133. package/lib/react/index.js +29 -0
  134. package/lib/react/shared/connect.d.ts +9 -0
  135. package/lib/react/shared/connect.js +118 -0
  136. package/lib/react/shared/context.d.ts +14 -0
  137. package/lib/react/shared/context.js +74 -0
  138. package/lib/react/shared/index.d.ts +2 -0
  139. package/lib/react/shared/index.js +23 -0
  140. package/lib/react/shared/render.d.ts +2 -0
  141. package/lib/react/shared/render.js +69 -0
  142. package/lib/react/types.d.ts +84 -0
  143. package/lib/react/types.js +15 -0
  144. package/lib/reactive/action.d.ts +2 -0
  145. package/lib/reactive/action.js +48 -0
  146. package/lib/reactive/annotations/box.d.ts +7 -0
  147. package/lib/reactive/annotations/box.js +76 -0
  148. package/lib/reactive/annotations/computed.d.ts +12 -0
  149. package/lib/reactive/annotations/computed.js +154 -0
  150. package/lib/reactive/annotations/index.d.ts +5 -0
  151. package/lib/reactive/annotations/index.js +29 -0
  152. package/lib/reactive/annotations/observable.d.ts +4 -0
  153. package/lib/reactive/annotations/observable.js +67 -0
  154. package/lib/reactive/annotations/ref.d.ts +6 -0
  155. package/lib/reactive/annotations/ref.js +78 -0
  156. package/lib/reactive/annotations/shallow.d.ts +2 -0
  157. package/lib/reactive/annotations/shallow.js +67 -0
  158. package/lib/reactive/array.d.ts +12 -0
  159. package/lib/reactive/array.js +83 -0
  160. package/lib/reactive/autorun.d.ts +7 -0
  161. package/lib/reactive/autorun.js +155 -0
  162. package/lib/reactive/batch.d.ts +2 -0
  163. package/lib/reactive/batch.js +40 -0
  164. package/lib/reactive/checkers.d.ts +10 -0
  165. package/lib/reactive/checkers.js +60 -0
  166. package/lib/reactive/environment.d.ts +28 -0
  167. package/lib/reactive/environment.js +76 -0
  168. package/lib/reactive/externals.d.ts +10 -0
  169. package/lib/reactive/externals.js +156 -0
  170. package/lib/reactive/global.d.js +0 -0
  171. package/lib/reactive/handlers.d.ts +4 -0
  172. package/lib/reactive/handlers.js +246 -0
  173. package/lib/reactive/index.d.ts +10 -0
  174. package/lib/reactive/index.js +39 -0
  175. package/lib/reactive/internals.d.ts +17 -0
  176. package/lib/reactive/internals.js +139 -0
  177. package/lib/reactive/model.d.ts +3 -0
  178. package/lib/reactive/model.js +68 -0
  179. package/lib/reactive/observable.d.ts +9 -0
  180. package/lib/reactive/observable.js +50 -0
  181. package/lib/reactive/observe.d.ts +2 -0
  182. package/lib/reactive/observe.js +58 -0
  183. package/lib/reactive/reaction.d.ts +21 -0
  184. package/lib/reactive/reaction.js +278 -0
  185. package/lib/reactive/tracker.d.ts +7 -0
  186. package/lib/reactive/tracker.js +63 -0
  187. package/lib/reactive/tree.d.ts +25 -0
  188. package/lib/reactive/tree.js +106 -0
  189. package/lib/reactive/types.d.ts +79 -0
  190. package/lib/reactive/types.js +21 -0
  191. package/lib/reactive/untracked.d.ts +4 -0
  192. package/lib/reactive/untracked.js +29 -0
  193. package/lib/reactive-react/hooks/index.d.ts +9 -0
  194. package/lib/reactive-react/hooks/index.js +48 -0
  195. package/lib/reactive-react/hooks/useCompatEffect.d.ts +2 -0
  196. package/lib/reactive-react/hooks/useCompatEffect.js +60 -0
  197. package/lib/reactive-react/hooks/useCompatFactory.d.ts +3 -0
  198. package/lib/reactive-react/hooks/useCompatFactory.js +74 -0
  199. package/lib/reactive-react/hooks/useDidUpdate.d.ts +1 -0
  200. package/lib/reactive-react/hooks/useDidUpdate.js +38 -0
  201. package/lib/reactive-react/hooks/useForceUpdate.d.ts +1 -0
  202. package/lib/reactive-react/hooks/useForceUpdate.js +76 -0
  203. package/lib/reactive-react/hooks/useLayoutEffect.d.ts +2 -0
  204. package/lib/reactive-react/hooks/useLayoutEffect.js +28 -0
  205. package/lib/reactive-react/hooks/useObserver.d.ts +2 -0
  206. package/lib/reactive-react/hooks/useObserver.js +43 -0
  207. package/lib/reactive-react/index.d.ts +3 -0
  208. package/lib/reactive-react/index.js +25 -0
  209. package/lib/reactive-react/observer.d.ts +8 -0
  210. package/lib/reactive-react/observer.js +64 -0
  211. package/lib/reactive-react/shared/gc.d.ts +8 -0
  212. package/lib/reactive-react/shared/gc.js +59 -0
  213. package/lib/reactive-react/shared/global.d.ts +1 -0
  214. package/lib/reactive-react/shared/global.js +50 -0
  215. package/lib/reactive-react/shared/immediate.d.ts +1 -0
  216. package/lib/reactive-react/shared/immediate.js +40 -0
  217. package/lib/reactive-react/shared/index.d.ts +2 -0
  218. package/lib/reactive-react/shared/index.js +23 -0
  219. package/lib/reactive-react/types.d.ts +14 -0
  220. package/lib/reactive-react/types.js +15 -0
  221. package/lib/shared/array.d.ts +35 -0
  222. package/lib/shared/array.js +189 -0
  223. package/lib/shared/case.d.ts +6 -0
  224. package/lib/shared/case.js +39 -0
  225. package/lib/shared/checkers.d.ts +21 -0
  226. package/lib/shared/checkers.js +77 -0
  227. package/lib/shared/clone.d.ts +2 -0
  228. package/lib/shared/clone.js +97 -0
  229. package/lib/shared/compare.d.ts +1 -0
  230. package/lib/shared/compare.js +129 -0
  231. package/lib/shared/defaults.d.ts +6 -0
  232. package/lib/shared/defaults.js +63 -0
  233. package/lib/shared/deprecate.d.ts +1 -0
  234. package/lib/shared/deprecate.js +42 -0
  235. package/lib/shared/global.d.ts +1 -0
  236. package/lib/shared/global.js +50 -0
  237. package/lib/shared/index.d.ts +16 -0
  238. package/lib/shared/index.js +51 -0
  239. package/lib/shared/instanceof.d.ts +1 -0
  240. package/lib/shared/instanceof.js +36 -0
  241. package/lib/shared/isEmpty.d.ts +3 -0
  242. package/lib/shared/isEmpty.js +94 -0
  243. package/lib/shared/merge.d.ts +12 -0
  244. package/lib/shared/merge.js +214 -0
  245. package/lib/shared/middleware.d.ts +4 -0
  246. package/lib/shared/middleware.js +41 -0
  247. package/lib/shared/path.d.ts +3 -0
  248. package/lib/shared/path.js +27 -0
  249. package/lib/shared/string.d.ts +1 -0
  250. package/lib/shared/string.js +38 -0
  251. package/lib/shared/subscribable.d.ts +11 -0
  252. package/lib/shared/subscribable.js +74 -0
  253. package/lib/shared/uid.d.ts +1 -0
  254. package/lib/shared/uid.js +35 -0
  255. package/lib/validator/formats.d.ts +16 -0
  256. package/lib/validator/formats.js +40 -0
  257. package/lib/validator/index.d.ts +4 -0
  258. package/lib/validator/index.js +27 -0
  259. package/lib/validator/locale.d.ts +219 -0
  260. package/lib/validator/locale.js +240 -0
  261. package/lib/validator/parser.d.ts +5 -0
  262. package/lib/validator/parser.js +153 -0
  263. package/lib/validator/registry.d.ts +15 -0
  264. package/lib/validator/registry.js +116 -0
  265. package/lib/validator/rules.d.ts +3 -0
  266. package/lib/validator/rules.js +154 -0
  267. package/lib/validator/template.d.ts +2 -0
  268. package/lib/validator/template.js +42 -0
  269. package/lib/validator/types.d.ts +62 -0
  270. package/lib/validator/types.js +28 -0
  271. package/lib/validator/validator.d.ts +2 -0
  272. package/lib/validator/validator.js +63 -0
  273. package/package.json +16 -10
@@ -0,0 +1,240 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+ var locale_exports = {};
19
+ __export(locale_exports, {
20
+ default: () => locale_default
21
+ });
22
+ module.exports = __toCommonJS(locale_exports);
23
+ var locale_default = {
24
+ en: {
25
+ pattern: "This field is invalid",
26
+ invalid: "This field is invalid",
27
+ required: "The field value is required",
28
+ number: "The field value is not a number",
29
+ integer: "The field value is not an integer number",
30
+ url: "The field value is a invalid url",
31
+ email: "The field value is not a email format",
32
+ ipv6: "The field value is not a ipv6 format",
33
+ ipv4: "The field value is not a ipv4 format",
34
+ idcard: "The field value is not an idcard format",
35
+ qq: "The field value is not a qq number format",
36
+ phone: "The field value is not a phone number format",
37
+ money: "The field value is not a currency format",
38
+ zh: "The field value is not a chinese string",
39
+ date: "The field value is not a valid date format",
40
+ zip: "The field value is not a zip format",
41
+ len: "The length or number of entries must be {{len}}",
42
+ min: "The length or number of entries must be at least {{min}}",
43
+ minLength: "The length or number of entries must be at least {{minLength}}",
44
+ minItems: "The length or number of entries must be at least {{minItems}}",
45
+ maximum: "The field value cannot be greater than {{maximum}}",
46
+ exclusiveMaximum: "The field value must be less than {{exclusiveMaximum}}",
47
+ minimum: "The field value cannot be less than {{minimum}}",
48
+ exclusiveMinimum: "The field value must be greater than {{exclusiveMinimum}}",
49
+ max: "The field length or number of entries must be at most {{max}}",
50
+ maxLength: "The field length or number of entries must be at most {{maxLength}}",
51
+ maxItems: "The field length or number of entries must be at most {{maxItems}}",
52
+ whitespace: "This field value cannot be blank string.",
53
+ enum: "The field value must be one of {{enum}}",
54
+ const: "The field value must be equal to {{const}}",
55
+ multipleOf: "The field value must be divisible by {{multipleOf}}",
56
+ maxProperties: "The number of field properties cannot be greater than {{maxProperties}}",
57
+ minProperties: "The number of field properties cannot be less than {{maxProperties}}",
58
+ uniqueItems: "Array elements are not unique"
59
+ },
60
+ zh: {
61
+ pattern: "\u8BE5\u5B57\u6BB5\u4E0D\u662F\u4E00\u4E2A\u5408\u6CD5\u7684\u5B57\u6BB5",
62
+ invalid: "\u8BE5\u5B57\u6BB5\u4E0D\u662F\u4E00\u4E2A\u5408\u6CD5\u7684\u5B57\u6BB5",
63
+ required: "\u8BE5\u5B57\u6BB5\u662F\u5FC5\u586B\u5B57\u6BB5",
64
+ number: "\u8BE5\u5B57\u6BB5\u4E0D\u662F\u5408\u6CD5\u7684\u6570\u5B57",
65
+ integer: "\u8BE5\u5B57\u6BB5\u4E0D\u662F\u5408\u6CD5\u7684\u6574\u578B\u6570\u5B57",
66
+ url: "\u8BE5\u5B57\u6BB5\u4E0D\u662F\u5408\u6CD5\u7684url",
67
+ email: "\u8BE5\u5B57\u6BB5\u4E0D\u662F\u5408\u6CD5\u7684\u90AE\u7BB1\u683C\u5F0F",
68
+ ipv6: "\u8BE5\u5B57\u6BB5\u4E0D\u662F\u5408\u6CD5\u7684ipv6\u683C\u5F0F",
69
+ ipv4: "\u8BE5\u5B57\u6BB5\u4E0D\u662F\u5408\u6CD5\u7684ipv4\u683C\u5F0F",
70
+ idcard: "\u8BE5\u5B57\u6BB5\u4E0D\u662F\u5408\u6CD5\u7684\u8EAB\u4EFD\u8BC1\u683C\u5F0F",
71
+ qq: "\u8BE5\u5B57\u6BB5\u4E0D\u7B26\u5408QQ\u53F7\u683C\u5F0F",
72
+ phone: "\u8BE5\u5B57\u6BB5\u4E0D\u662F\u6709\u6548\u7684\u624B\u673A\u53F7",
73
+ money: "\u8BE5\u5B57\u6BB5\u4E0D\u662F\u6709\u6548\u8D27\u5E01\u683C\u5F0F",
74
+ zh: "\u8BE5\u5B57\u6BB5\u4E0D\u662F\u5408\u6CD5\u7684\u4E2D\u6587\u5B57\u7B26\u4E32",
75
+ date: "\u8BE5\u5B57\u6BB5\u4E0D\u662F\u5408\u6CD5\u7684\u65E5\u671F\u683C\u5F0F",
76
+ zip: "\u8BE5\u5B57\u6BB5\u4E0D\u662F\u5408\u6CD5\u7684\u90AE\u7F16\u683C\u5F0F",
77
+ len: "\u957F\u5EA6\u6216\u6761\u76EE\u6570\u5FC5\u987B\u4E3A{{len}}",
78
+ min: "\u957F\u5EA6\u6216\u6761\u76EE\u6570\u4E0D\u80FD\u5C0F\u4E8E{{min}}",
79
+ minLength: "\u957F\u5EA6\u6216\u6761\u76EE\u6570\u4E0D\u80FD\u5C0F\u4E8E{{minLength}}",
80
+ minItems: "\u957F\u5EA6\u6216\u6761\u76EE\u6570\u4E0D\u80FD\u5C0F\u4E8E{{minItems}}",
81
+ max: "\u957F\u5EA6\u6216\u6761\u76EE\u6570\u4E0D\u80FD\u5927\u4E8E{{max}}",
82
+ maxLength: "\u957F\u5EA6\u6216\u6761\u76EE\u6570\u4E0D\u80FD\u5927\u4E8E{{maxLength}}",
83
+ maxItems: "\u957F\u5EA6\u6216\u6761\u76EE\u6570\u4E0D\u80FD\u5927\u4E8E{{maxItems}}",
84
+ maximum: "\u6570\u503C\u4E0D\u80FD\u5927\u4E8E{{maximum}}",
85
+ exclusiveMaximum: "\u6570\u503C\u5FC5\u987B\u5C0F\u4E8E{{exclusiveMaximum}}",
86
+ minimum: "\u6570\u503C\u4E0D\u80FD\u5C0F\u4E8E{{minimum}}",
87
+ exclusiveMinimum: "\u6570\u503C\u5FC5\u987B\u5927\u4E8E{{exclusiveMinimum}}",
88
+ whitespace: "\u4E0D\u80FD\u4E3A\u7EAF\u7A7A\u767D\u5B57\u7B26\u4E32",
89
+ enum: "\u5B57\u6BB5\u503C\u5FC5\u987B\u4E3A{{enum}}\u5176\u4E2D\u4E00\u4E2A",
90
+ const: "\u5B57\u6BB5\u503C\u5FC5\u987B\u7B49\u4E8E{{const}}",
91
+ multipleOf: "\u5B57\u6BB5\u503C\u4E0D\u80FD\u88AB{{multipleOf}}\u6574\u9664",
92
+ maxProperties: "\u5B57\u6BB5\u5C5E\u6027\u6570\u91CF\u4E0D\u80FD\u5927\u4E8E{{maxProperties}}",
93
+ minProperties: "\u5B57\u6BB5\u5C5E\u6027\u6570\u91CF\u4E0D\u80FD\u5C0F\u4E8E{{minProperties}}",
94
+ uniqueItems: "\u6570\u7EC4\u5143\u7D20\u4E0D\u552F\u4E00"
95
+ },
96
+ "en-US": {
97
+ pattern: "This field is invalid",
98
+ invalid: "This field is invalid",
99
+ required: "The field value is required",
100
+ number: "The field value is not a number",
101
+ integer: "The field value is not an integer number",
102
+ url: "The field value is a invalid url",
103
+ email: "The field value is not a email format",
104
+ ipv6: "The field value is not a ipv6 format",
105
+ ipv4: "The field value is not a ipv4 format",
106
+ idcard: "The field value is not an idcard format",
107
+ qq: "The field value is not a qq number format",
108
+ phone: "The field value is not a phone number format",
109
+ money: "The field value is not a currency format",
110
+ zh: "The field value is not a chinese string",
111
+ date: "The field value is not a valid date format",
112
+ zip: "The field value is not a zip format",
113
+ len: "The length or number of entries must be {{len}}",
114
+ min: "The length or number of entries must be at least {{min}}",
115
+ minLength: "The length or number of entries must be at least {{minLength}}",
116
+ minItems: "The length or number of entries must be at least {{minItems}}",
117
+ maximum: "The field value cannot be greater than {{maximum}}",
118
+ exclusiveMaximum: "The field value must be less than {{exclusiveMaximum}}",
119
+ minimum: "The field value cannot be less than {{minimum}}",
120
+ exclusiveMinimum: "The field value must be greater than {{exclusiveMinimum}}",
121
+ max: "The field length or number of entries must be at most {{max}}",
122
+ maxLength: "The field length or number of entries must be at most {{maxLength}}",
123
+ maxItems: "The field length or number of entries must be at most {{maxItems}}",
124
+ whitespace: "This field value cannot be blank string.",
125
+ enum: "The field value must be one of {{enum}}",
126
+ const: "The field value must be equal to {{const}}",
127
+ multipleOf: "The field value must be divisible by {{multipleOf}}",
128
+ maxProperties: "The number of field properties cannot be greater than {{maxProperties}}",
129
+ minProperties: "The number of field properties cannot be less than {{maxProperties}}",
130
+ uniqueItems: "Array elements are not unique"
131
+ },
132
+ "zh-CN": {
133
+ pattern: "\u8BE5\u5B57\u6BB5\u4E0D\u662F\u4E00\u4E2A\u5408\u6CD5\u7684\u5B57\u6BB5",
134
+ invalid: "\u8BE5\u5B57\u6BB5\u4E0D\u662F\u4E00\u4E2A\u5408\u6CD5\u7684\u5B57\u6BB5",
135
+ required: "\u8BE5\u5B57\u6BB5\u662F\u5FC5\u586B\u5B57\u6BB5",
136
+ number: "\u8BE5\u5B57\u6BB5\u4E0D\u662F\u5408\u6CD5\u7684\u6570\u5B57",
137
+ integer: "\u8BE5\u5B57\u6BB5\u4E0D\u662F\u5408\u6CD5\u7684\u6574\u578B\u6570\u5B57",
138
+ url: "\u8BE5\u5B57\u6BB5\u4E0D\u662F\u5408\u6CD5\u7684url",
139
+ email: "\u8BE5\u5B57\u6BB5\u4E0D\u662F\u5408\u6CD5\u7684\u90AE\u7BB1\u683C\u5F0F",
140
+ ipv6: "\u8BE5\u5B57\u6BB5\u4E0D\u662F\u5408\u6CD5\u7684ipv6\u683C\u5F0F",
141
+ ipv4: "\u8BE5\u5B57\u6BB5\u4E0D\u662F\u5408\u6CD5\u7684ipv4\u683C\u5F0F",
142
+ idcard: "\u8BE5\u5B57\u6BB5\u4E0D\u662F\u5408\u6CD5\u7684\u8EAB\u4EFD\u8BC1\u683C\u5F0F",
143
+ qq: "\u8BE5\u5B57\u6BB5\u4E0D\u7B26\u5408QQ\u53F7\u683C\u5F0F",
144
+ phone: "\u8BE5\u5B57\u6BB5\u4E0D\u662F\u6709\u6548\u7684\u624B\u673A\u53F7",
145
+ money: "\u8BE5\u5B57\u6BB5\u4E0D\u662F\u6709\u6548\u8D27\u5E01\u683C\u5F0F",
146
+ zh: "\u8BE5\u5B57\u6BB5\u4E0D\u662F\u5408\u6CD5\u7684\u4E2D\u6587\u5B57\u7B26\u4E32",
147
+ date: "\u8BE5\u5B57\u6BB5\u4E0D\u662F\u5408\u6CD5\u7684\u65E5\u671F\u683C\u5F0F",
148
+ zip: "\u8BE5\u5B57\u6BB5\u4E0D\u662F\u5408\u6CD5\u7684\u90AE\u7F16\u683C\u5F0F",
149
+ len: "\u957F\u5EA6\u6216\u6761\u76EE\u6570\u5FC5\u987B\u4E3A{{len}}",
150
+ min: "\u957F\u5EA6\u6216\u6761\u76EE\u6570\u4E0D\u80FD\u5C0F\u4E8E{{min}}",
151
+ minLength: "\u957F\u5EA6\u6216\u6761\u76EE\u6570\u4E0D\u80FD\u5C0F\u4E8E{{minLength}}",
152
+ minItems: "\u957F\u5EA6\u6216\u6761\u76EE\u6570\u4E0D\u80FD\u5C0F\u4E8E{{minItems}}",
153
+ maxLength: "\u957F\u5EA6\u6216\u6761\u76EE\u6570\u4E0D\u80FD\u5927\u4E8E{{maxLength}}",
154
+ maxItems: "\u957F\u5EA6\u6216\u6761\u76EE\u6570\u4E0D\u80FD\u5927\u4E8E{{maxItems}}",
155
+ max: "\u957F\u5EA6\u6216\u6761\u76EE\u6570\u4E0D\u80FD\u5927\u4E8E{{max}}",
156
+ maximum: "\u6570\u503C\u4E0D\u80FD\u5927\u4E8E{{maximum}}",
157
+ exclusiveMaximum: "\u6570\u503C\u5FC5\u987B\u5C0F\u4E8E{{exclusiveMaximum}}",
158
+ minimum: "\u6570\u503C\u4E0D\u80FD\u5C0F\u4E8E{{minimum}}",
159
+ exclusiveMinimum: "\u6570\u503C\u5FC5\u987B\u5927\u4E8E{{exclusiveMinimum}}",
160
+ whitespace: "\u4E0D\u80FD\u4E3A\u7EAF\u7A7A\u767D\u5B57\u7B26\u4E32",
161
+ enum: "\u5B57\u6BB5\u503C\u5FC5\u987B\u4E3A{{enum}}\u5176\u4E2D\u4E00\u4E2A",
162
+ const: "\u5B57\u6BB5\u503C\u5FC5\u987B\u7B49\u4E8E{{const}}",
163
+ multipleOf: "\u5B57\u6BB5\u503C\u4E0D\u80FD\u88AB{{multipleOf}}\u6574\u9664",
164
+ maxProperties: "\u5B57\u6BB5\u5C5E\u6027\u6570\u91CF\u4E0D\u80FD\u5927\u4E8E{{maxProperties}}",
165
+ minProperties: "\u5B57\u6BB5\u5C5E\u6027\u6570\u91CF\u4E0D\u80FD\u5C0F\u4E8E{{minProperties}}",
166
+ uniqueItems: "\u6570\u7EC4\u5143\u7D20\u4E0D\u552F\u4E00"
167
+ },
168
+ "zh-TW": {
169
+ pattern: "\u8A72\u5B57\u6BB5\u4E0D\u662F\u4E00\u500B\u5408\u6CD5\u7684\u5B57\u6BB5",
170
+ invalid: "\u8A72\u5B57\u6BB5\u4E0D\u662F\u4E00\u500B\u5408\u6CD5\u7684\u5B57\u6BB5",
171
+ required: "\u8A72\u5B57\u6BB5\u662F\u5FC5\u586B\u5B57\u6BB5",
172
+ number: "\u8A72\u5B57\u6BB5\u4E0D\u662F\u5408\u6CD5\u7684\u6578\u5B57",
173
+ integer: "\u8A72\u5B57\u6BB5\u4E0D\u662F\u5408\u6CD5\u7684\u6574\u578B\u6578\u5B57",
174
+ url: "\u8A72\u5B57\u6BB5\u4E0D\u662F\u5408\u6CD5\u7684url",
175
+ email: "\u8A72\u5B57\u6BB5\u4E0D\u662F\u5408\u6CD5\u7684\u90F5\u7BB1\u683C\u5F0F",
176
+ ipv6: "\u8A72\u5B57\u6BB5\u4E0D\u662F\u5408\u6CD5\u7684ipv6\u683C\u5F0F",
177
+ ipv4: "\u8A72\u5B57\u6BB5\u4E0D\u662F\u5408\u6CD5\u7684ipv4\u683C\u5F0F",
178
+ idcard: "\u8A72\u5B57\u6BB5\u4E0D\u662F\u5408\u6CD5\u7684\u8EAB\u4EFD\u8B49\u683C\u5F0F",
179
+ qq: "\u8A72\u5B57\u6BB5\u4E0D\u7B26\u5408QQ\u865F\u683C\u5F0F",
180
+ phone: "\u8A72\u5B57\u6BB5\u4E0D\u662F\u6709\u6548\u7684\u624B\u6A5F\u865F",
181
+ money: "\u8A72\u5B57\u6BB5\u4E0D\u662F\u6709\u6548\u8CA8\u5E63\u683C\u5F0F",
182
+ zh: "\u8A72\u5B57\u6BB5\u4E0D\u662F\u5408\u6CD5\u7684\u4E2D\u6587\u5B57\u7B26\u4E32",
183
+ date: "\u8A72\u5B57\u6BB5\u4E0D\u662F\u5408\u6CD5\u7684\u65E5\u671F\u683C\u5F0F",
184
+ zip: "\u8A72\u5B57\u6BB5\u4E0D\u662F\u5408\u6CD5\u7684\u90F5\u7DE8\u683C\u5F0F",
185
+ len: "\u9577\u5EA6\u6216\u689D\u76EE\u6578\u5FC5\u9808\u70BA{{len}}",
186
+ min: "\u9577\u5EA6\u6216\u689D\u76EE\u6578\u4E0D\u80FD\u5C0F\u65BC{{min}}",
187
+ minItems: "\u9577\u5EA6\u6216\u689D\u76EE\u6578\u4E0D\u80FD\u5C0F\u65BC{{minItems}}",
188
+ minLength: "\u9577\u5EA6\u6216\u689D\u76EE\u6578\u4E0D\u80FD\u5C0F\u65BC{{minLength}}",
189
+ max: "\u9577\u5EA6\u6216\u689D\u76EE\u6578\u4E0D\u80FD\u5927\u65BC{{max}}",
190
+ maxItems: "\u9577\u5EA6\u6216\u689D\u76EE\u6578\u4E0D\u80FD\u5927\u65BC{{maxItems}}",
191
+ maxLength: "\u9577\u5EA6\u6216\u689D\u76EE\u6578\u4E0D\u80FD\u5927\u65BC{{maxLength}}",
192
+ maximum: "\u6578\u503C\u4E0D\u80FD\u5927\u65BC{{maximum}}",
193
+ exclusiveMaximum: "\u6578\u503C\u5FC5\u9808\u5C0F\u65BC{{exclusiveMaximum}}",
194
+ minimum: "\u6578\u503C\u4E0D\u80FD\u5C0F\u65BC{{minimum}}",
195
+ exclusiveMinimum: "\u6578\u503C\u5FC5\u9808\u5927\u65BC{{exclusiveMinimum}}",
196
+ whitespace: "\u4E0D\u80FD\u70BA\u7D14\u7A7A\u767D\u5B57\u7B26\u4E32",
197
+ enum: "\u5B57\u6BB5\u503C\u5FC5\u9808\u70BA{{enum}}\u5176\u4E2D\u4E00\u500B",
198
+ const: "\u5B57\u6BB5\u503C\u5FC5\u9808\u7B49\u65BC{{const}}",
199
+ multipleOf: "\u5B57\u6BB5\u503C\u4E0D\u80FD\u88AB{{multipleOf}}\u6574\u9664",
200
+ maxProperties: "\u5B57\u6BB5\u5C6C\u6027\u6578\u91CF\u4E0D\u80FD\u5927\u65BC{{maxProperties}}",
201
+ minProperties: "\u5B57\u6BB5\u5C6C\u6027\u6578\u91CF\u4E0D\u80FD\u5C0F\u65BC{{minProperties}}",
202
+ uniqueItems: "\u6578\u7D44\u5143\u7D20\u4E0D\u552F\u4E00"
203
+ },
204
+ ja: {
205
+ url: "\u3053\u306E\u30D5\u30A3\u30FC\u30EB\u30C9\u306F\u7121\u52B9\u306AURL\u3067\u3059",
206
+ whitespace: "\u3053\u306E\u30D5\u30A3\u30FC\u30EB\u30C9\u3092\u7A7A\u306E\u6587\u5B57\u5217\u306B\u3059\u308B\u3053\u3068\u306F\u3067\u304D\u307E\u305B\u3093\u3002",
207
+ zh: "\u3053\u306E\u30D5\u30A3\u30FC\u30EB\u30C9\u306F\u4E2D\u56FD\u8A9E\u306E\u6587\u5B57\u5217\u3067\u306F\u3042\u308A\u307E\u305B\u3093",
208
+ zip: "\u3053\u306E\u30D5\u30A3\u30FC\u30EB\u30C9\u306Fzip\u5F62\u5F0F\u3067\u306F\u3042\u308A\u307E\u305B\u3093",
209
+ date: "\u3053\u306E\u30D5\u30A3\u30FC\u30EB\u30C9\u306F\u6709\u52B9\u306A\u65E5\u4ED8\u5F62\u5F0F\u3067\u306F\u3042\u308A\u307E\u305B\u3093",
210
+ email: "\u3053\u306E\u30D5\u30A3\u30FC\u30EB\u30C9\u306F\u30E1\u30FC\u30EB\u5F62\u5F0F\u3067\u306F\u3042\u308A\u307E\u305B\u3093",
211
+ exclusiveMaximum: "\u5024\u306F{{exclusiveMaximum}}\u672A\u6E80\u3067\u3042\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059",
212
+ exclusiveMinimum: "\u5024\u306F{{exclusiveMinimum}}\u3088\u308A\u5927\u304D\u3044\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059",
213
+ idcard: "\u3053\u306E\u30D5\u30A3\u30FC\u30EB\u30C9\u306FID\u30AB\u30FC\u30C9\u5F62\u5F0F\u3067\u306F\u3042\u308A\u307E\u305B\u3093",
214
+ integer: "\u3053\u306E\u30D5\u30A3\u30FC\u30EB\u30C9\u306F\u6574\u6570\u3067\u306F\u3042\u308A\u307E\u305B\u3093",
215
+ ipv4: "\u3053\u306E\u30D5\u30A3\u30FC\u30EB\u30C9\u306FIPv4\u5F62\u5F0F\u3067\u306F\u3042\u308A\u307E\u305B\u3093",
216
+ ipv6: "\u3053\u306E\u30D5\u30A3\u30FC\u30EB\u30C9\u306FIPv6\u5F62\u5F0F\u3067\u306F\u3042\u308A\u307E\u305B\u3093",
217
+ len: "\u30A8\u30F3\u30C8\u30EA\u306E\u9577\u3055\u307E\u305F\u306F\u6570\u306F{{len}}\u3067\u306A\u3051\u308C\u3070\u306A\u308A\u307E\u305B\u3093",
218
+ max: "\u30A8\u30F3\u30C8\u30EA\u306E\u9577\u3055\u307E\u305F\u306F\u6570\u306F\u6700\u5927{{max}}\u3067\u306A\u3051\u308C\u3070\u306A\u308A\u307E\u305B\u3093",
219
+ maxItems: "\u30A8\u30F3\u30C8\u30EA\u306E\u9577\u3055\u307E\u305F\u306F\u6570\u306F\u6700\u5927{{maxItems}}\u3067\u306A\u3051\u308C\u3070\u306A\u308A\u307E\u305B\u3093",
220
+ maxLength: "\u30A8\u30F3\u30C8\u30EA\u306E\u9577\u3055\u307E\u305F\u306F\u6570\u306F\u6700\u5927{{maxLength}}\u3067\u306A\u3051\u308C\u3070\u306A\u308A\u307E\u305B\u3093",
221
+ maximum: "\u5024\u306F{{\u6700\u5927}}\u3092\u8D85\u3048\u308B\u3053\u3068\u306F\u3067\u304D\u307E\u305B\u3093",
222
+ min: "\u30A8\u30F3\u30C8\u30EA\u306E\u9577\u3055\u307E\u305F\u306F\u6570\u306F\u3001\u5C11\u306A\u304F\u3068\u3082{{min}}\u3067\u3042\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059",
223
+ minItems: "\u30A8\u30F3\u30C8\u30EA\u306E\u9577\u3055\u307E\u305F\u306F\u6570\u306F\u3001\u5C11\u306A\u304F\u3068\u3082{{minItems}}\u3067\u3042\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059",
224
+ minLength: "\u30A8\u30F3\u30C8\u30EA\u306E\u9577\u3055\u307E\u305F\u306F\u6570\u306F\u3001\u5C11\u306A\u304F\u3068\u3082{{minLength}}\u3067\u3042\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059",
225
+ minimum: "\u5024\u306F{{minimum}}\u4EE5\u4E0A\u306B\u3059\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059",
226
+ money: "\u3053\u306E\u30D5\u30A3\u30FC\u30EB\u30C9\u306F\u901A\u8CA8\u5F62\u5F0F\u3067\u306F\u3042\u308A\u307E\u305B\u3093",
227
+ number: "\u3053\u306E\u30D5\u30A3\u30FC\u30EB\u30C9\u306F\u6570\u5024\u3067\u306F\u3042\u308A\u307E\u305B\u3093",
228
+ pattern: "\u3053\u306E\u30D5\u30A3\u30FC\u30EB\u30C9\u306F\u3069\u306E\u30D1\u30BF\u30FC\u30F3\u3068\u3082\u4E00\u81F4\u3057\u307E\u305B\u3093",
229
+ invalid: "\u3053\u306E\u30D5\u30A3\u30FC\u30EB\u30C9\u306F\u3069\u306E\u30D1\u30BF\u30FC\u30F3\u3068\u3082\u4E00\u81F4\u3057\u307E\u305B\u3093",
230
+ phone: "\u3053\u306E\u30D5\u30A3\u30FC\u30EB\u30C9\u306F\u96FB\u8A71\u756A\u53F7\u306E\u5F62\u5F0F\u3067\u306F\u3042\u308A\u307E\u305B\u3093",
231
+ qq: "\u3053\u306E\u30D5\u30A3\u30FC\u30EB\u30C9\u306Fqq\u6570\u5024\u5F62\u5F0F\u3067\u306F\u3042\u308A\u307E\u305B\u3093",
232
+ required: "\u3053\u306E\u9805\u76EE\u306F\u5FC5\u9808\u3067\u3059",
233
+ enum: "\u30D5\u30A3\u30FC\u30EB\u30C9\u5024\u306F{{enum}}\u306E\u3044\u305A\u308C\u304B\u3067\u3042\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059",
234
+ cons: "\u30D5\u30A3\u30FC\u30EB\u30C9\u5024\u306F{{const}}\u3068\u7B49\u3057\u304F\u306A\u3051\u308C\u3070\u306A\u308A\u307E\u305B\u3093",
235
+ multipleOf: "\u30D5\u30A3\u30FC\u30EB\u30C9\u5024\u3092{{multipleOf}}\u3067\u5272\u308A\u5207\u308C\u306A\u3044",
236
+ maxProperties: "\u30D5\u30A3\u30FC\u30EB\u30C9\u30D7\u30ED\u30D1\u30C6\u30A3\u306E\u6570\u306F{{maxProperties}}\u3092\u8D85\u3048\u308B\u3053\u3068\u306F\u3067\u304D\u307E\u305B\u3093",
237
+ minProperties: "\u30D5\u30A3\u30FC\u30EB\u30C9\u30D7\u30ED\u30D1\u30C6\u30A3\u306E\u6570\u306F{{minProperties}}\u672A\u6E80\u306B\u3059\u308B\u3053\u3068\u306F\u3067\u304D\u307E\u305B\u3093",
238
+ uniqueItems: "\u914D\u5217\u8981\u7D20\u306F\u4E00\u610F\u3067\u306F\u3042\u308A\u307E\u305B\u3093"
239
+ }
240
+ };
@@ -0,0 +1,5 @@
1
+ import { IValidatorOptions, IValidatorRules, Validator, ValidatorDescription, ValidatorParsedFunction } from './types';
2
+ export declare const parseValidatorDescription: (description: ValidatorDescription) => IValidatorRules;
3
+ export declare const parseValidatorDescriptions: <Context = any>(validator: Validator<Context>) => IValidatorRules[];
4
+ export declare const parseValidatorRules: (rules?: IValidatorRules) => ValidatorParsedFunction[];
5
+ export declare const parseValidator: <Context = any>(validator: Validator<Context>, options?: IValidatorOptions) => ValidatorParsedFunction<Context>[];
@@ -0,0 +1,153 @@
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 parser_exports = {};
20
+ __export(parser_exports, {
21
+ parseValidator: () => parseValidator,
22
+ parseValidatorDescription: () => parseValidatorDescription,
23
+ parseValidatorDescriptions: () => parseValidatorDescriptions,
24
+ parseValidatorRules: () => parseValidatorRules
25
+ });
26
+ module.exports = __toCommonJS(parser_exports);
27
+ var import_shared = require("../shared");
28
+ var import_registry = require("./registry");
29
+ var import_template = require("./template");
30
+ var import_types = require("./types");
31
+ const getRuleMessage = /* @__PURE__ */ __name((rule, type) => {
32
+ if (rule.format) {
33
+ return rule.message || (0, import_registry.getValidateLocale)(rule.format);
34
+ }
35
+ return rule.message || (0, import_registry.getValidateLocale)(type);
36
+ }, "getRuleMessage");
37
+ const parseValidatorDescription = /* @__PURE__ */ __name((description) => {
38
+ if (!description) return {};
39
+ let rules = {};
40
+ if ((0, import_shared.isStr)(description)) {
41
+ rules.format = description;
42
+ } else if ((0, import_shared.isFn)(description)) {
43
+ rules.validator = description;
44
+ } else {
45
+ rules = Object.assign(rules, description);
46
+ }
47
+ return rules;
48
+ }, "parseValidatorDescription");
49
+ const parseValidatorDescriptions = /* @__PURE__ */ __name((validator) => {
50
+ if (!validator) return [];
51
+ const array = (0, import_shared.isArr)(validator) ? validator : [validator];
52
+ return array.map((description) => {
53
+ return parseValidatorDescription(description);
54
+ });
55
+ }, "parseValidatorDescriptions");
56
+ const parseValidatorRules = /* @__PURE__ */ __name((rules = {}) => {
57
+ const getRulesKeys = /* @__PURE__ */ __name(() => {
58
+ const keys = [];
59
+ if ("required" in rules) {
60
+ keys.push("required");
61
+ }
62
+ for (let key in rules) {
63
+ if (key === "required" || key === "validator") continue;
64
+ keys.push(key);
65
+ }
66
+ if ("validator" in rules) {
67
+ keys.push("validator");
68
+ }
69
+ return keys;
70
+ }, "getRulesKeys");
71
+ const getContext = /* @__PURE__ */ __name((context, value) => {
72
+ return {
73
+ ...rules,
74
+ ...context,
75
+ value
76
+ };
77
+ }, "getContext");
78
+ const createValidate = /* @__PURE__ */ __name((callback, message) => async (value, context) => {
79
+ const context_ = getContext(context, value);
80
+ try {
81
+ const results = await callback(value, { ...rules, message }, context_, (message2, scope) => {
82
+ var _a;
83
+ return (_a = (0, import_template.render)(
84
+ {
85
+ type: "error",
86
+ message: message2
87
+ },
88
+ Object.assign(context_, scope)
89
+ )) == null ? void 0 : _a.message;
90
+ });
91
+ if ((0, import_shared.isBool)(results)) {
92
+ if (!results) {
93
+ return (0, import_template.render)(
94
+ {
95
+ type: "error",
96
+ message
97
+ },
98
+ context_
99
+ );
100
+ }
101
+ return {
102
+ type: "error",
103
+ message: void 0
104
+ };
105
+ } else if (results) {
106
+ if ((0, import_types.isValidateResult)(results)) {
107
+ return (0, import_template.render)(results, context_);
108
+ }
109
+ return (0, import_template.render)(
110
+ {
111
+ type: "error",
112
+ message: results
113
+ },
114
+ context_
115
+ );
116
+ }
117
+ return {
118
+ type: "error",
119
+ message: void 0
120
+ };
121
+ } catch (e) {
122
+ return {
123
+ type: "error",
124
+ message: (e == null ? void 0 : e.message) || e
125
+ };
126
+ }
127
+ }, "createValidate");
128
+ return getRulesKeys().reduce((buf, key) => {
129
+ const callback = (0, import_registry.getValidateRules)(key);
130
+ if (callback) {
131
+ const validator = createValidate(callback, getRuleMessage(rules, key));
132
+ return buf.concat(validator);
133
+ }
134
+ return buf;
135
+ }, []);
136
+ }, "parseValidatorRules");
137
+ const parseValidator = /* @__PURE__ */ __name((validator, options = {}) => {
138
+ if (!validator) return [];
139
+ const array = (0, import_shared.isArr)(validator) ? validator : [validator];
140
+ return array.reduce((buf, description) => {
141
+ const rules = parseValidatorDescription(description);
142
+ const triggerType = rules.triggerType ?? "onInput";
143
+ if ((options == null ? void 0 : options.triggerType) && options.triggerType !== triggerType) return buf;
144
+ return rules ? buf.concat(parseValidatorRules(rules)) : buf;
145
+ }, []);
146
+ }, "parseValidator");
147
+ // Annotate the CommonJS export names for ESM import in node:
148
+ 0 && (module.exports = {
149
+ parseValidator,
150
+ parseValidatorDescription,
151
+ parseValidatorDescriptions,
152
+ parseValidatorRules
153
+ });
@@ -0,0 +1,15 @@
1
+ import { IRegistryFormats, IRegistryLocales, IRegistryRules, ValidatorFunction, ValidatorFunctionResponse } from './types';
2
+ export declare const getValidateLocaleIOSCode: (language: string) => any;
3
+ export declare const setValidateLanguage: (lang: string) => void;
4
+ export declare const getValidateLanguage: () => any;
5
+ export declare const getLocaleByPath: (path: string, lang?: string) => any;
6
+ export declare const getValidateLocale: (path: string) => any;
7
+ export declare const getValidateMessageTemplateEngine: () => any;
8
+ export declare const getValidateFormats: (key?: string) => any;
9
+ export declare const getValidateRules: <T>(key?: T) => T extends string ? ValidatorFunction : {
10
+ [key: string]: ValidatorFunction;
11
+ };
12
+ export declare const registerValidateLocale: (locale: IRegistryLocales) => void;
13
+ export declare const registerValidateRules: (rules: IRegistryRules) => void;
14
+ export declare const registerValidateFormats: (formats: IRegistryFormats) => void;
15
+ export declare const registerValidateMessageTemplateEngine: (template: (message: ValidatorFunctionResponse, context: any) => any) => void;
@@ -0,0 +1,116 @@
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 registry_exports = {};
20
+ __export(registry_exports, {
21
+ getLocaleByPath: () => getLocaleByPath,
22
+ getValidateFormats: () => getValidateFormats,
23
+ getValidateLanguage: () => getValidateLanguage,
24
+ getValidateLocale: () => getValidateLocale,
25
+ getValidateLocaleIOSCode: () => getValidateLocaleIOSCode,
26
+ getValidateMessageTemplateEngine: () => getValidateMessageTemplateEngine,
27
+ getValidateRules: () => getValidateRules,
28
+ registerValidateFormats: () => registerValidateFormats,
29
+ registerValidateLocale: () => registerValidateLocale,
30
+ registerValidateMessageTemplateEngine: () => registerValidateMessageTemplateEngine,
31
+ registerValidateRules: () => registerValidateRules,
32
+ setValidateLanguage: () => setValidateLanguage
33
+ });
34
+ module.exports = __toCommonJS(registry_exports);
35
+ var import_shared = require("../shared");
36
+ const getIn = import_shared.FormPath.getIn;
37
+ const self = import_shared.globalThisPolyfill;
38
+ const defaultLanguage = "en";
39
+ const getBrowserlanguage = /* @__PURE__ */ __name(() => {
40
+ if (!self.navigator) {
41
+ return defaultLanguage;
42
+ }
43
+ return self.navigator.browserlanguage || self.navigator.language || defaultLanguage;
44
+ }, "getBrowserlanguage");
45
+ const registry = {
46
+ locales: {
47
+ messages: {},
48
+ language: getBrowserlanguage()
49
+ },
50
+ formats: {},
51
+ rules: {},
52
+ template: null
53
+ };
54
+ const getISOCode = /* @__PURE__ */ __name((language) => {
55
+ let isoCode = registry.locales.language;
56
+ if (registry.locales.messages[language]) {
57
+ return language;
58
+ }
59
+ const lang = (0, import_shared.lowerCase)(language);
60
+ (0, import_shared.each)(registry.locales.messages, (messages, key) => {
61
+ const target = (0, import_shared.lowerCase)(key);
62
+ if (target.indexOf(lang) > -1 || lang.indexOf(target) > -1) {
63
+ isoCode = key;
64
+ return false;
65
+ }
66
+ });
67
+ return isoCode;
68
+ }, "getISOCode");
69
+ const getValidateLocaleIOSCode = getISOCode;
70
+ const setValidateLanguage = /* @__PURE__ */ __name((lang) => {
71
+ registry.locales.language = lang || defaultLanguage;
72
+ }, "setValidateLanguage");
73
+ const getValidateLanguage = /* @__PURE__ */ __name(() => registry.locales.language, "getValidateLanguage");
74
+ const getLocaleByPath = /* @__PURE__ */ __name((path, lang = registry.locales.language) => getIn(registry.locales.messages, `${getISOCode(lang)}.${path}`), "getLocaleByPath");
75
+ const getValidateLocale = /* @__PURE__ */ __name((path) => {
76
+ const message = getLocaleByPath(path);
77
+ return message || getLocaleByPath("pattern") || getLocaleByPath("pattern", defaultLanguage);
78
+ }, "getValidateLocale");
79
+ const getValidateMessageTemplateEngine = /* @__PURE__ */ __name(() => registry.template, "getValidateMessageTemplateEngine");
80
+ const getValidateFormats = /* @__PURE__ */ __name((key) => key ? registry.formats[key] : registry.formats, "getValidateFormats");
81
+ const getValidateRules = /* @__PURE__ */ __name((key) => key ? registry.rules[key] : registry.rules, "getValidateRules");
82
+ const registerValidateLocale = /* @__PURE__ */ __name((locale) => {
83
+ registry.locales.messages = (0, import_shared.merge)(registry.locales.messages, locale);
84
+ }, "registerValidateLocale");
85
+ const registerValidateRules = /* @__PURE__ */ __name((rules) => {
86
+ (0, import_shared.each)(rules, (rule, key) => {
87
+ if ((0, import_shared.isFn)(rule)) {
88
+ registry.rules[key] = rule;
89
+ }
90
+ });
91
+ }, "registerValidateRules");
92
+ const registerValidateFormats = /* @__PURE__ */ __name((formats) => {
93
+ (0, import_shared.each)(formats, (pattern, key) => {
94
+ if ((0, import_shared.isStr)(pattern) || pattern instanceof RegExp) {
95
+ registry.formats[key] = new RegExp(pattern);
96
+ }
97
+ });
98
+ }, "registerValidateFormats");
99
+ const registerValidateMessageTemplateEngine = /* @__PURE__ */ __name((template) => {
100
+ registry.template = template;
101
+ }, "registerValidateMessageTemplateEngine");
102
+ // Annotate the CommonJS export names for ESM import in node:
103
+ 0 && (module.exports = {
104
+ getLocaleByPath,
105
+ getValidateFormats,
106
+ getValidateLanguage,
107
+ getValidateLocale,
108
+ getValidateLocaleIOSCode,
109
+ getValidateMessageTemplateEngine,
110
+ getValidateRules,
111
+ registerValidateFormats,
112
+ registerValidateLocale,
113
+ registerValidateMessageTemplateEngine,
114
+ registerValidateRules,
115
+ setValidateLanguage
116
+ });
@@ -0,0 +1,3 @@
1
+ import { IRegistryRules } from './types';
2
+ declare const RULES: IRegistryRules;
3
+ export default RULES;