@formvk/validator 0.0.0-stage → 1.0.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/CHANGELOG.md +12 -0
- package/README.md +63 -2
- package/dist/index.d.ts +118 -0
- package/dist/index.js +487 -0
- package/dist/index.js.map +1 -0
- package/package.json +20 -3
package/CHANGELOG.md
ADDED
package/README.md
CHANGED
|
@@ -1,3 +1,64 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @formvk/validator
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Standalone validation engine used by Formvk, with a rule registry, format validators, localized messages and validator description parsing.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pnpm add @formvk/validator
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
```ts
|
|
14
|
+
import { validate } from '@formvk/validator'
|
|
15
|
+
|
|
16
|
+
const results = await validate('alice', [
|
|
17
|
+
{ required: true, message: 'Username is required' },
|
|
18
|
+
{ minLength: 3, maxLength: 20, message: 'Use 3–20 characters' },
|
|
19
|
+
])
|
|
20
|
+
|
|
21
|
+
results.error.length === 0 // true
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
Register custom rules and formats:
|
|
25
|
+
|
|
26
|
+
```ts
|
|
27
|
+
import { registerValidateFormats, registerValidateRules } from '@formvk/validator'
|
|
28
|
+
|
|
29
|
+
registerValidateRules({
|
|
30
|
+
isEven: value => (typeof value === 'number' && value % 2 === 0 ? '' : 'Must be an even number'),
|
|
31
|
+
})
|
|
32
|
+
|
|
33
|
+
registerValidateFormats({
|
|
34
|
+
hex: /^#[0-9a-f]{6}$/i,
|
|
35
|
+
})
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
Switch the built-in language (`en`, `zh`, `ja`):
|
|
39
|
+
|
|
40
|
+
```ts
|
|
41
|
+
import { setValidateLanguage } from '@formvk/validator'
|
|
42
|
+
|
|
43
|
+
setValidateLanguage('zh')
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## API
|
|
47
|
+
|
|
48
|
+
- **Validate** — `validate(value, validator, options?)` → `{ error, success, warning }`.
|
|
49
|
+
- **Parse** — `parseValidator`, `parseValidatorRules`, `parseValidatorDescription`, `parseValidatorDescriptions`.
|
|
50
|
+
- **Registry** — `registerValidateRules`, `registerValidateFormats`, `registerValidateLocale`, `registerValidateMessageTemplateEngine`, `getValidateRules`, `getValidateFormats`, `getValidateLocale`.
|
|
51
|
+
- **Language** — `setValidateLanguage`, `getValidateLanguage`, `getLocaleByPath`.
|
|
52
|
+
- **Built-in rules** — `required`, `max`, `min`, `exclusiveMaximum`, `exclusiveMinimum`, `len`, `pattern`, `whitespace`, `enum`, `const`, `multipleOf`, `uniqueItems`, `maxProperties`, `minProperties`, plus aliases such as `maxLength`, `minLength`, `maxItems`, `minItems`, `maximum`, `minimum`.
|
|
53
|
+
- **Built-in formats** — `url`, `email`, `number`, `integer`, `qq`, `phone`, `idcard`, `money`, `zh`, `date`, `zip`.
|
|
54
|
+
|
|
55
|
+
`@formvk/schema` accepts these rules directly on schema fields through `validator`.
|
|
56
|
+
|
|
57
|
+
## Documentation
|
|
58
|
+
|
|
59
|
+
- Validator API: https://formvk.github.io/core/api/validator
|
|
60
|
+
- Validation guide: https://formvk.github.io/core/guide/validation
|
|
61
|
+
|
|
62
|
+
## License
|
|
63
|
+
|
|
64
|
+
MIT
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
declare function getISOCode(language: string): any;
|
|
2
|
+
|
|
3
|
+
export declare function getLocaleByPath(path: string, lang?: string): any;
|
|
4
|
+
|
|
5
|
+
export declare function getValidateFormats(key?: string): any;
|
|
6
|
+
|
|
7
|
+
export declare function getValidateLanguage(): any;
|
|
8
|
+
|
|
9
|
+
export declare function getValidateLocale(path: string): any;
|
|
10
|
+
|
|
11
|
+
export declare const getValidateLocaleIOSCode: typeof getISOCode;
|
|
12
|
+
|
|
13
|
+
export declare function getValidateMessageTemplateEngine(): any;
|
|
14
|
+
|
|
15
|
+
export declare function getValidateRules<T>(key?: T): T extends string ? ValidatorFunction : {
|
|
16
|
+
[key: string]: ValidatorFunction;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export declare interface IRegistryFormats {
|
|
20
|
+
[key: string]: string | RegExp;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export declare interface IRegistryLocaleMessages {
|
|
24
|
+
[key: string]: string | IRegistryLocaleMessages;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export declare interface IRegistryLocales {
|
|
28
|
+
[language: string]: IRegistryLocaleMessages;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export declare interface IRegistryRules<Context = any> {
|
|
32
|
+
[key: string]: ValidatorFunction<Context>;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export declare function isValidateResult(obj: any): obj is IValidateResult;
|
|
36
|
+
|
|
37
|
+
export declare interface IValidateResult {
|
|
38
|
+
type: 'error' | 'warning' | 'success' | (string & {});
|
|
39
|
+
message: string;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export declare interface IValidateResults {
|
|
43
|
+
error?: string[];
|
|
44
|
+
warning?: string[];
|
|
45
|
+
success?: string[];
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export declare interface IValidatorOptions<Context = any> {
|
|
49
|
+
validateFirst?: boolean;
|
|
50
|
+
triggerType?: ValidatorTriggerType;
|
|
51
|
+
context?: Context;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export declare interface IValidatorRules<Context = any> {
|
|
55
|
+
triggerType?: ValidatorTriggerType;
|
|
56
|
+
format?: ValidatorFormats;
|
|
57
|
+
validator?: ValidatorFunction<Context>;
|
|
58
|
+
required?: boolean;
|
|
59
|
+
pattern?: RegExp | string;
|
|
60
|
+
max?: number;
|
|
61
|
+
maximum?: number;
|
|
62
|
+
maxItems?: number;
|
|
63
|
+
minItems?: number;
|
|
64
|
+
maxLength?: number;
|
|
65
|
+
minLength?: number;
|
|
66
|
+
exclusiveMaximum?: number;
|
|
67
|
+
exclusiveMinimum?: number;
|
|
68
|
+
minimum?: number;
|
|
69
|
+
min?: number;
|
|
70
|
+
len?: number;
|
|
71
|
+
whitespace?: boolean;
|
|
72
|
+
enum?: any[];
|
|
73
|
+
const?: any;
|
|
74
|
+
multipleOf?: number;
|
|
75
|
+
uniqueItems?: boolean;
|
|
76
|
+
maxProperties?: number;
|
|
77
|
+
minProperties?: number;
|
|
78
|
+
message?: string;
|
|
79
|
+
[key: string]: any;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export declare type MultiValidator<Context = any> = ValidatorDescription<Context>[];
|
|
83
|
+
|
|
84
|
+
export declare function parseValidator<Context = any>(validator?: Validator<Context>, options?: IValidatorOptions): ValidatorParsedFunction<Context>[];
|
|
85
|
+
|
|
86
|
+
export declare function parseValidatorDescription(description: ValidatorDescription): IValidatorRules;
|
|
87
|
+
|
|
88
|
+
export declare function parseValidatorDescriptions<Context = any>(validator?: Validator<Context>): IValidatorRules[];
|
|
89
|
+
|
|
90
|
+
export declare function parseValidatorRules(rules?: IValidatorRules): ValidatorParsedFunction[];
|
|
91
|
+
|
|
92
|
+
export declare function registerValidateFormats(formats: IRegistryFormats): void;
|
|
93
|
+
|
|
94
|
+
export declare function registerValidateLocale(locale: IRegistryLocales): void;
|
|
95
|
+
|
|
96
|
+
export declare function registerValidateMessageTemplateEngine(template: (message: ValidatorFunctionResponse, context: any) => any): void;
|
|
97
|
+
|
|
98
|
+
export declare function registerValidateRules(rules: IRegistryRules): void;
|
|
99
|
+
|
|
100
|
+
export declare function setValidateLanguage(lang: string): void;
|
|
101
|
+
|
|
102
|
+
export declare function validate<Context = any>(value: any, validator?: Validator<Context>, options?: IValidatorOptions<Context>): Promise<IValidateResults>;
|
|
103
|
+
|
|
104
|
+
export declare type Validator<Context = any> = ValidatorDescription<Context> | MultiValidator<Context>;
|
|
105
|
+
|
|
106
|
+
export declare type ValidatorDescription<Context = any> = ValidatorFormats | ValidatorFunction<Context> | IValidatorRules<Context>;
|
|
107
|
+
|
|
108
|
+
export declare type ValidatorFormats = 'url' | 'email' | 'ipv6' | 'ipv4' | 'number' | 'integer' | 'idcard' | 'qq' | 'phone' | 'money' | 'zh' | 'date' | 'zip' | (string & {});
|
|
109
|
+
|
|
110
|
+
export declare type ValidatorFunction<Context = any> = (value: any, rule: IValidatorRules<Context>, ctx: Context, render: (message: string, scope?: any) => string) => ValidatorFunctionResponse | Promise<ValidatorFunctionResponse>;
|
|
111
|
+
|
|
112
|
+
export declare type ValidatorFunctionResponse = string | boolean | IValidateResult | undefined | null;
|
|
113
|
+
|
|
114
|
+
export declare type ValidatorParsedFunction<Context = any> = (value: any, ctx?: Context) => IValidateResult | Promise<IValidateResult> | null;
|
|
115
|
+
|
|
116
|
+
export declare type ValidatorTriggerType = 'onInput' | 'onFocus' | 'onBlur' | (string & {});
|
|
117
|
+
|
|
118
|
+
export { }
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,487 @@
|
|
|
1
|
+
import { FormPath as e, each as t, globalThisPolyfill as n, isArr as r, isBool as i, isEmpty as a, isEqual as o, isFn as s, isNum as c, isStr as l, isValid as u, lowerCase as d, merge as f, stringLength as p, toArr as m } from "@formvk/shared";
|
|
2
|
+
// src/formats.ts
|
|
3
|
+
var h = {
|
|
4
|
+
url: /* @__PURE__ */ RegExp("^(?:(?:(?:https?|ftp|rtmp):)?//)(?:\\S+(?::\\S*)?@)?(?:(?!(?:10|127)(?:\\.\\d{1,3}){3})(?!(?:169\\.254|192\\.168)(?:\\.\\d{1,3}){2})(?!172\\.(?:1[6-9]|2\\d|3[0-1])(?:\\.\\d{1,3}){2})(?:22[0-3]|2[01]\\d|[1-9]\\d?|1\\d\\d)(?:\\.(?:25[0-5]|2[0-4]\\d|1?\\d{1,2})){2}(?:\\.(?:25[0-4]|2[0-4]\\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fa-f]{1,4}){1,6})|((:[0-9A-Fa-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9A-Fa-f]{1,4}){1,7})|((:[0-9A-Fa-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))(%.+)?\s*$/,
|
|
7
|
+
ipv4: /^((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\.){3}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})$/,
|
|
8
|
+
number: /^[+-]?\d+(\.\d+)?$/,
|
|
9
|
+
integer: /^[+-]?\d+$/,
|
|
10
|
+
qq: /^(\+?[1-9]\d*|0)$/,
|
|
11
|
+
phone: /^\d{3}-\d{8}$|^\d{4}-\d{7}$|^\d{11}$/,
|
|
12
|
+
idcard: /^\d{15}$|^\d{17}(\d|x|X)$/,
|
|
13
|
+
money: /^([\u0024\u00A2\u00A3\u00A4\u20AC\u00A5\u20B1\u20B9\uFFE5]\s*)(\d+,?)+(\.\d+)?\s*$/,
|
|
14
|
+
zh: /^[\u4e00-\u9fa5]+$/,
|
|
15
|
+
date: /^[0-9]+[./-][0-9]+[./-][0-9]+\s*(?:[0-9]+\s*:\s*[0-9]+\s*:\s*[0-9]+)?$/,
|
|
16
|
+
zip: /^[0-9]{6}$/
|
|
17
|
+
}, g = {
|
|
18
|
+
en: {
|
|
19
|
+
pattern: "This field is invalid",
|
|
20
|
+
invalid: "This field is invalid",
|
|
21
|
+
required: "The field value is required",
|
|
22
|
+
number: "The field value is not a number",
|
|
23
|
+
integer: "The field value is not an integer number",
|
|
24
|
+
url: "The field value is a invalid url",
|
|
25
|
+
email: "The field value is not a email format",
|
|
26
|
+
ipv6: "The field value is not a ipv6 format",
|
|
27
|
+
ipv4: "The field value is not a ipv4 format",
|
|
28
|
+
idcard: "The field value is not an idcard format",
|
|
29
|
+
qq: "The field value is not a qq number format",
|
|
30
|
+
phone: "The field value is not a phone number format",
|
|
31
|
+
money: "The field value is not a currency format",
|
|
32
|
+
zh: "The field value is not a chinese string",
|
|
33
|
+
date: "The field value is not a valid date format",
|
|
34
|
+
zip: "The field value is not a zip format",
|
|
35
|
+
len: "The length or number of entries must be {{len}}",
|
|
36
|
+
min: "The length or number of entries must be at least {{min}}",
|
|
37
|
+
minLength: "The length or number of entries must be at least {{minLength}}",
|
|
38
|
+
minItems: "The length or number of entries must be at least {{minItems}}",
|
|
39
|
+
maximum: "The field value cannot be greater than {{maximum}}",
|
|
40
|
+
exclusiveMaximum: "The field value must be less than {{exclusiveMaximum}}",
|
|
41
|
+
minimum: "The field value cannot be less than {{minimum}}",
|
|
42
|
+
exclusiveMinimum: "The field value must be greater than {{exclusiveMinimum}}",
|
|
43
|
+
max: "The field length or number of entries must be at most {{max}}",
|
|
44
|
+
maxLength: "The field length or number of entries must be at most {{maxLength}}",
|
|
45
|
+
maxItems: "The field length or number of entries must be at most {{maxItems}}",
|
|
46
|
+
whitespace: "This field value cannot be blank string.",
|
|
47
|
+
enum: "The field value must be one of {{enum}}",
|
|
48
|
+
const: "The field value must be equal to {{const}}",
|
|
49
|
+
multipleOf: "The field value must be divisible by {{multipleOf}}",
|
|
50
|
+
maxProperties: "The number of field properties cannot be greater than {{maxProperties}}",
|
|
51
|
+
minProperties: "The number of field properties cannot be less than {{maxProperties}}",
|
|
52
|
+
uniqueItems: "Array elements are not unique"
|
|
53
|
+
},
|
|
54
|
+
zh: {
|
|
55
|
+
pattern: "该字段不是一个合法的字段",
|
|
56
|
+
invalid: "该字段不是一个合法的字段",
|
|
57
|
+
required: "该字段是必填字段",
|
|
58
|
+
number: "该字段不是合法的数字",
|
|
59
|
+
integer: "该字段不是合法的整型数字",
|
|
60
|
+
url: "该字段不是合法的url",
|
|
61
|
+
email: "该字段不是合法的邮箱格式",
|
|
62
|
+
ipv6: "该字段不是合法的ipv6格式",
|
|
63
|
+
ipv4: "该字段不是合法的ipv4格式",
|
|
64
|
+
idcard: "该字段不是合法的身份证格式",
|
|
65
|
+
qq: "该字段不符合QQ号格式",
|
|
66
|
+
phone: "该字段不是有效的手机号",
|
|
67
|
+
money: "该字段不是有效货币格式",
|
|
68
|
+
zh: "该字段不是合法的中文字符串",
|
|
69
|
+
date: "该字段不是合法的日期格式",
|
|
70
|
+
zip: "该字段不是合法的邮编格式",
|
|
71
|
+
len: "长度或条目数必须为{{len}}",
|
|
72
|
+
min: "长度或条目数不能小于{{min}}",
|
|
73
|
+
minLength: "长度或条目数不能小于{{minLength}}",
|
|
74
|
+
minItems: "长度或条目数不能小于{{minItems}}",
|
|
75
|
+
max: "长度或条目数不能大于{{max}}",
|
|
76
|
+
maxLength: "长度或条目数不能大于{{maxLength}}",
|
|
77
|
+
maxItems: "长度或条目数不能大于{{maxItems}}",
|
|
78
|
+
maximum: "数值不能大于{{maximum}}",
|
|
79
|
+
exclusiveMaximum: "数值必须小于{{exclusiveMaximum}}",
|
|
80
|
+
minimum: "数值不能小于{{minimum}}",
|
|
81
|
+
exclusiveMinimum: "数值必须大于{{exclusiveMinimum}}",
|
|
82
|
+
whitespace: "不能为纯空白字符串",
|
|
83
|
+
enum: "字段值必须为{{enum}}其中一个",
|
|
84
|
+
const: "字段值必须等于{{const}}",
|
|
85
|
+
multipleOf: "字段值不能被{{multipleOf}}整除",
|
|
86
|
+
maxProperties: "字段属性数量不能大于{{maxProperties}}",
|
|
87
|
+
minProperties: "字段属性数量不能小于{{minProperties}}",
|
|
88
|
+
uniqueItems: "数组元素不唯一"
|
|
89
|
+
},
|
|
90
|
+
"en-US": {
|
|
91
|
+
pattern: "This field is invalid",
|
|
92
|
+
invalid: "This field is invalid",
|
|
93
|
+
required: "The field value is required",
|
|
94
|
+
number: "The field value is not a number",
|
|
95
|
+
integer: "The field value is not an integer number",
|
|
96
|
+
url: "The field value is a invalid url",
|
|
97
|
+
email: "The field value is not a email format",
|
|
98
|
+
ipv6: "The field value is not a ipv6 format",
|
|
99
|
+
ipv4: "The field value is not a ipv4 format",
|
|
100
|
+
idcard: "The field value is not an idcard format",
|
|
101
|
+
qq: "The field value is not a qq number format",
|
|
102
|
+
phone: "The field value is not a phone number format",
|
|
103
|
+
money: "The field value is not a currency format",
|
|
104
|
+
zh: "The field value is not a chinese string",
|
|
105
|
+
date: "The field value is not a valid date format",
|
|
106
|
+
zip: "The field value is not a zip format",
|
|
107
|
+
len: "The length or number of entries must be {{len}}",
|
|
108
|
+
min: "The length or number of entries must be at least {{min}}",
|
|
109
|
+
minLength: "The length or number of entries must be at least {{minLength}}",
|
|
110
|
+
minItems: "The length or number of entries must be at least {{minItems}}",
|
|
111
|
+
maximum: "The field value cannot be greater than {{maximum}}",
|
|
112
|
+
exclusiveMaximum: "The field value must be less than {{exclusiveMaximum}}",
|
|
113
|
+
minimum: "The field value cannot be less than {{minimum}}",
|
|
114
|
+
exclusiveMinimum: "The field value must be greater than {{exclusiveMinimum}}",
|
|
115
|
+
max: "The field length or number of entries must be at most {{max}}",
|
|
116
|
+
maxLength: "The field length or number of entries must be at most {{maxLength}}",
|
|
117
|
+
maxItems: "The field length or number of entries must be at most {{maxItems}}",
|
|
118
|
+
whitespace: "This field value cannot be blank string.",
|
|
119
|
+
enum: "The field value must be one of {{enum}}",
|
|
120
|
+
const: "The field value must be equal to {{const}}",
|
|
121
|
+
multipleOf: "The field value must be divisible by {{multipleOf}}",
|
|
122
|
+
maxProperties: "The number of field properties cannot be greater than {{maxProperties}}",
|
|
123
|
+
minProperties: "The number of field properties cannot be less than {{maxProperties}}",
|
|
124
|
+
uniqueItems: "Array elements are not unique"
|
|
125
|
+
},
|
|
126
|
+
"zh-CN": {
|
|
127
|
+
pattern: "该字段不是一个合法的字段",
|
|
128
|
+
invalid: "该字段不是一个合法的字段",
|
|
129
|
+
required: "该字段是必填字段",
|
|
130
|
+
number: "该字段不是合法的数字",
|
|
131
|
+
integer: "该字段不是合法的整型数字",
|
|
132
|
+
url: "该字段不是合法的url",
|
|
133
|
+
email: "该字段不是合法的邮箱格式",
|
|
134
|
+
ipv6: "该字段不是合法的ipv6格式",
|
|
135
|
+
ipv4: "该字段不是合法的ipv4格式",
|
|
136
|
+
idcard: "该字段不是合法的身份证格式",
|
|
137
|
+
qq: "该字段不符合QQ号格式",
|
|
138
|
+
phone: "该字段不是有效的手机号",
|
|
139
|
+
money: "该字段不是有效货币格式",
|
|
140
|
+
zh: "该字段不是合法的中文字符串",
|
|
141
|
+
date: "该字段不是合法的日期格式",
|
|
142
|
+
zip: "该字段不是合法的邮编格式",
|
|
143
|
+
len: "长度或条目数必须为{{len}}",
|
|
144
|
+
min: "长度或条目数不能小于{{min}}",
|
|
145
|
+
minLength: "长度或条目数不能小于{{minLength}}",
|
|
146
|
+
minItems: "长度或条目数不能小于{{minItems}}",
|
|
147
|
+
maxLength: "长度或条目数不能大于{{maxLength}}",
|
|
148
|
+
maxItems: "长度或条目数不能大于{{maxItems}}",
|
|
149
|
+
max: "长度或条目数不能大于{{max}}",
|
|
150
|
+
maximum: "数值不能大于{{maximum}}",
|
|
151
|
+
exclusiveMaximum: "数值必须小于{{exclusiveMaximum}}",
|
|
152
|
+
minimum: "数值不能小于{{minimum}}",
|
|
153
|
+
exclusiveMinimum: "数值必须大于{{exclusiveMinimum}}",
|
|
154
|
+
whitespace: "不能为纯空白字符串",
|
|
155
|
+
enum: "字段值必须为{{enum}}其中一个",
|
|
156
|
+
const: "字段值必须等于{{const}}",
|
|
157
|
+
multipleOf: "字段值不能被{{multipleOf}}整除",
|
|
158
|
+
maxProperties: "字段属性数量不能大于{{maxProperties}}",
|
|
159
|
+
minProperties: "字段属性数量不能小于{{minProperties}}",
|
|
160
|
+
uniqueItems: "数组元素不唯一"
|
|
161
|
+
},
|
|
162
|
+
"zh-TW": {
|
|
163
|
+
pattern: "該字段不是一個合法的字段",
|
|
164
|
+
invalid: "該字段不是一個合法的字段",
|
|
165
|
+
required: "該字段是必填字段",
|
|
166
|
+
number: "該字段不是合法的數字",
|
|
167
|
+
integer: "該字段不是合法的整型數字",
|
|
168
|
+
url: "該字段不是合法的url",
|
|
169
|
+
email: "該字段不是合法的郵箱格式",
|
|
170
|
+
ipv6: "該字段不是合法的ipv6格式",
|
|
171
|
+
ipv4: "該字段不是合法的ipv4格式",
|
|
172
|
+
idcard: "該字段不是合法的身份證格式",
|
|
173
|
+
qq: "該字段不符合QQ號格式",
|
|
174
|
+
phone: "該字段不是有效的手機號",
|
|
175
|
+
money: "該字段不是有效貨幣格式",
|
|
176
|
+
zh: "該字段不是合法的中文字符串",
|
|
177
|
+
date: "該字段不是合法的日期格式",
|
|
178
|
+
zip: "該字段不是合法的郵編格式",
|
|
179
|
+
len: "長度或條目數必須為{{len}}",
|
|
180
|
+
min: "長度或條目數不能小於{{min}}",
|
|
181
|
+
minItems: "長度或條目數不能小於{{minItems}}",
|
|
182
|
+
minLength: "長度或條目數不能小於{{minLength}}",
|
|
183
|
+
max: "長度或條目數不能大於{{max}}",
|
|
184
|
+
maxItems: "長度或條目數不能大於{{maxItems}}",
|
|
185
|
+
maxLength: "長度或條目數不能大於{{maxLength}}",
|
|
186
|
+
maximum: "數值不能大於{{maximum}}",
|
|
187
|
+
exclusiveMaximum: "數值必須小於{{exclusiveMaximum}}",
|
|
188
|
+
minimum: "數值不能小於{{minimum}}",
|
|
189
|
+
exclusiveMinimum: "數值必須大於{{exclusiveMinimum}}",
|
|
190
|
+
whitespace: "不能為純空白字符串",
|
|
191
|
+
enum: "字段值必須為{{enum}}其中一個",
|
|
192
|
+
const: "字段值必須等於{{const}}",
|
|
193
|
+
multipleOf: "字段值不能被{{multipleOf}}整除",
|
|
194
|
+
maxProperties: "字段屬性數量不能大於{{maxProperties}}",
|
|
195
|
+
minProperties: "字段屬性數量不能小於{{minProperties}}",
|
|
196
|
+
uniqueItems: "數組元素不唯一"
|
|
197
|
+
},
|
|
198
|
+
ja: {
|
|
199
|
+
url: "このフィールドは無効なURLです",
|
|
200
|
+
whitespace: "このフィールドを空の文字列にすることはできません。",
|
|
201
|
+
zh: "このフィールドは中国語の文字列ではありません",
|
|
202
|
+
zip: "このフィールドはzip形式ではありません",
|
|
203
|
+
date: "このフィールドは有効な日付形式ではありません",
|
|
204
|
+
email: "このフィールドはメール形式ではありません",
|
|
205
|
+
exclusiveMaximum: "値は{{exclusiveMaximum}}未満である必要があります",
|
|
206
|
+
exclusiveMinimum: "値は{{exclusiveMinimum}}より大きい必要があります",
|
|
207
|
+
idcard: "このフィールドはIDカード形式ではありません",
|
|
208
|
+
integer: "このフィールドは整数ではありません",
|
|
209
|
+
ipv4: "このフィールドはIPv4形式ではありません",
|
|
210
|
+
ipv6: "このフィールドはIPv6形式ではありません",
|
|
211
|
+
len: "エントリの長さまたは数は{{len}}でなければなりません",
|
|
212
|
+
max: "エントリの長さまたは数は最大{{max}}でなければなりません",
|
|
213
|
+
maxItems: "エントリの長さまたは数は最大{{maxItems}}でなければなりません",
|
|
214
|
+
maxLength: "エントリの長さまたは数は最大{{maxLength}}でなければなりません",
|
|
215
|
+
maximum: "値は{{最大}}を超えることはできません",
|
|
216
|
+
min: "エントリの長さまたは数は、少なくとも{{min}}である必要があります",
|
|
217
|
+
minItems: "エントリの長さまたは数は、少なくとも{{minItems}}である必要があります",
|
|
218
|
+
minLength: "エントリの長さまたは数は、少なくとも{{minLength}}である必要があります",
|
|
219
|
+
minimum: "値は{{minimum}}以上にする必要があります",
|
|
220
|
+
money: "このフィールドは通貨形式ではありません",
|
|
221
|
+
number: "このフィールドは数値ではありません",
|
|
222
|
+
pattern: "このフィールドはどのパターンとも一致しません",
|
|
223
|
+
invalid: "このフィールドはどのパターンとも一致しません",
|
|
224
|
+
phone: "このフィールドは電話番号の形式ではありません",
|
|
225
|
+
qq: "このフィールドはqq数値形式ではありません",
|
|
226
|
+
required: "この項目は必須です",
|
|
227
|
+
enum: "フィールド値は{{enum}}のいずれかである必要があります",
|
|
228
|
+
cons: "フィールド値は{{const}}と等しくなければなりません",
|
|
229
|
+
multipleOf: "フィールド値を{{multipleOf}}で割り切れない",
|
|
230
|
+
maxProperties: "フィールドプロパティの数は{{maxProperties}}を超えることはできません",
|
|
231
|
+
minProperties: "フィールドプロパティの数は{{minProperties}}未満にすることはできません",
|
|
232
|
+
uniqueItems: "配列要素は一意ではありません"
|
|
233
|
+
}
|
|
234
|
+
}, _ = e.getIn, v = n, y = "en";
|
|
235
|
+
function b() {
|
|
236
|
+
return v.navigator && v.navigator.language || y;
|
|
237
|
+
}
|
|
238
|
+
var x = {
|
|
239
|
+
locales: {
|
|
240
|
+
messages: {},
|
|
241
|
+
language: b()
|
|
242
|
+
},
|
|
243
|
+
formats: {},
|
|
244
|
+
rules: {},
|
|
245
|
+
template: null
|
|
246
|
+
};
|
|
247
|
+
function S(e) {
|
|
248
|
+
let n = x.locales.language;
|
|
249
|
+
if (x.locales.messages[e]) return e;
|
|
250
|
+
let r = d(e);
|
|
251
|
+
return t(x.locales.messages, (e, t) => {
|
|
252
|
+
let i = d(t);
|
|
253
|
+
if (i.indexOf(r) > -1 || r.indexOf(i) > -1) return n = t, !1;
|
|
254
|
+
}), n;
|
|
255
|
+
}
|
|
256
|
+
var C = S;
|
|
257
|
+
function w(e) {
|
|
258
|
+
x.locales.language = e || y;
|
|
259
|
+
}
|
|
260
|
+
function T() {
|
|
261
|
+
return x.locales.language;
|
|
262
|
+
}
|
|
263
|
+
function E(e, t = x.locales.language) {
|
|
264
|
+
return _(x.locales.messages, `${S(t)}.${e}`);
|
|
265
|
+
}
|
|
266
|
+
function D(e) {
|
|
267
|
+
return E(e) || E("pattern") || E("pattern", y);
|
|
268
|
+
}
|
|
269
|
+
function O() {
|
|
270
|
+
return x.template;
|
|
271
|
+
}
|
|
272
|
+
function k(e) {
|
|
273
|
+
return e ? x.formats[e] : x.formats;
|
|
274
|
+
}
|
|
275
|
+
function A(e) {
|
|
276
|
+
return e ? x.rules[e] : x.rules;
|
|
277
|
+
}
|
|
278
|
+
function j(e) {
|
|
279
|
+
x.locales.messages = f(x.locales.messages, e);
|
|
280
|
+
}
|
|
281
|
+
function M(e) {
|
|
282
|
+
t(e, (e, t) => {
|
|
283
|
+
s(e) && (x.rules[t] = e);
|
|
284
|
+
});
|
|
285
|
+
}
|
|
286
|
+
function N(e) {
|
|
287
|
+
t(e, (e, t) => {
|
|
288
|
+
(l(e) || e instanceof RegExp) && (x.formats[t] = new RegExp(e));
|
|
289
|
+
});
|
|
290
|
+
}
|
|
291
|
+
function P(e) {
|
|
292
|
+
x.template = e;
|
|
293
|
+
}
|
|
294
|
+
// src/template.ts
|
|
295
|
+
function F(t, n) {
|
|
296
|
+
let { message: r } = t;
|
|
297
|
+
if (l(r)) {
|
|
298
|
+
let i = O();
|
|
299
|
+
s(i) && (t.message = i(r, n)), t.message = t.message.replace(/\{\{\s*([\w.]+)\s*\}\}/g, (t, r) => e.getIn(n, r));
|
|
300
|
+
}
|
|
301
|
+
return t;
|
|
302
|
+
}
|
|
303
|
+
// src/types.ts
|
|
304
|
+
function I(e) {
|
|
305
|
+
return !!e.type && !!e.message;
|
|
306
|
+
}
|
|
307
|
+
// src/parser.ts
|
|
308
|
+
function L(e, t) {
|
|
309
|
+
return e.format ? e.message || D(e.format) : e.message || D(t);
|
|
310
|
+
}
|
|
311
|
+
function R(e) {
|
|
312
|
+
if (!e) return {};
|
|
313
|
+
let t = {};
|
|
314
|
+
return l(e) ? t.format = e : s(e) ? t.validator = e : t = Object.assign(t, e), t;
|
|
315
|
+
}
|
|
316
|
+
function z(e) {
|
|
317
|
+
return e ? (r(e) ? e : [e]).map((e) => R(e)) : [];
|
|
318
|
+
}
|
|
319
|
+
function B(e = {}) {
|
|
320
|
+
function t() {
|
|
321
|
+
let t = [];
|
|
322
|
+
"required" in e && t.push("required");
|
|
323
|
+
for (let n in e) n !== "required" && n !== "validator" && t.push(n);
|
|
324
|
+
return "validator" in e && t.push("validator"), t;
|
|
325
|
+
}
|
|
326
|
+
function n(t, n) {
|
|
327
|
+
return {
|
|
328
|
+
...e,
|
|
329
|
+
...t,
|
|
330
|
+
value: n
|
|
331
|
+
};
|
|
332
|
+
}
|
|
333
|
+
function r(t, r) {
|
|
334
|
+
return async (a, o) => {
|
|
335
|
+
let s = n(o, a);
|
|
336
|
+
try {
|
|
337
|
+
let n = await t(a, {
|
|
338
|
+
...e,
|
|
339
|
+
message: r
|
|
340
|
+
}, s, (e, t) => F({
|
|
341
|
+
type: "error",
|
|
342
|
+
message: e
|
|
343
|
+
}, Object.assign(s, t))?.message);
|
|
344
|
+
return i(n) ? n ? {
|
|
345
|
+
type: "error",
|
|
346
|
+
message: void 0
|
|
347
|
+
} : F({
|
|
348
|
+
type: "error",
|
|
349
|
+
message: r
|
|
350
|
+
}, s) : n ? I(n) ? F(n, s) : F({
|
|
351
|
+
type: "error",
|
|
352
|
+
message: n
|
|
353
|
+
}, s) : {
|
|
354
|
+
type: "error",
|
|
355
|
+
message: void 0
|
|
356
|
+
};
|
|
357
|
+
} catch (e) {
|
|
358
|
+
return {
|
|
359
|
+
type: "error",
|
|
360
|
+
message: e?.message || e
|
|
361
|
+
};
|
|
362
|
+
}
|
|
363
|
+
};
|
|
364
|
+
}
|
|
365
|
+
return t().reduce((t, n) => {
|
|
366
|
+
let i = A(n);
|
|
367
|
+
if (i) {
|
|
368
|
+
let a = r(i, L(e, n));
|
|
369
|
+
return t.concat(a);
|
|
370
|
+
}
|
|
371
|
+
return t;
|
|
372
|
+
}, []);
|
|
373
|
+
}
|
|
374
|
+
function V(e, t = {}) {
|
|
375
|
+
return e ? (r(e) ? e : [e]).reduce((e, n) => {
|
|
376
|
+
let r = R(n), i = r.triggerType ?? "onInput";
|
|
377
|
+
return t?.triggerType && t.triggerType !== i ? e : r ? e.concat(B(r)) : e;
|
|
378
|
+
}, []) : [];
|
|
379
|
+
}
|
|
380
|
+
// src/rules.ts
|
|
381
|
+
function H(e) {
|
|
382
|
+
if (r(e)) {
|
|
383
|
+
for (let t = 0; t < e.length; t++) if (u(e[t])) return !1;
|
|
384
|
+
return !0;
|
|
385
|
+
}
|
|
386
|
+
return e?.getCurrentContent ? !e.getCurrentContent()?.hasText() : a(e);
|
|
387
|
+
}
|
|
388
|
+
function U(e) {
|
|
389
|
+
return l(e) ? p(e) : e ? e.length : 0;
|
|
390
|
+
}
|
|
391
|
+
function W(e, n) {
|
|
392
|
+
t(n, (t, n) => {
|
|
393
|
+
e[n] = (r, i, ...a) => e[t](r, {
|
|
394
|
+
...i,
|
|
395
|
+
[t]: i[n]
|
|
396
|
+
}, ...a);
|
|
397
|
+
});
|
|
398
|
+
}
|
|
399
|
+
var G = {
|
|
400
|
+
format(e, t) {
|
|
401
|
+
if (H(e)) return "";
|
|
402
|
+
if (t.format) {
|
|
403
|
+
let n = k(t.format);
|
|
404
|
+
if (n) return new RegExp(n).test(e) ? "" : t.message;
|
|
405
|
+
}
|
|
406
|
+
return "";
|
|
407
|
+
},
|
|
408
|
+
required(e, t) {
|
|
409
|
+
return t.required === !1 ? "" : H(e) ? t.message : "";
|
|
410
|
+
},
|
|
411
|
+
max(e, t) {
|
|
412
|
+
return H(e) ? "" : (c(e) ? e : U(e)) > Number(t.max) ? t.message : "";
|
|
413
|
+
},
|
|
414
|
+
min(e, t) {
|
|
415
|
+
return H(e) ? "" : (c(e) ? e : U(e)) < Number(t.min) ? t.message : "";
|
|
416
|
+
},
|
|
417
|
+
exclusiveMaximum(e, t) {
|
|
418
|
+
return H(e) ? "" : (c(e) ? e : U(e)) >= Number(t.exclusiveMaximum) ? t.message : "";
|
|
419
|
+
},
|
|
420
|
+
exclusiveMinimum(e, t) {
|
|
421
|
+
return H(e) ? "" : (c(e) ? e : U(e)) <= Number(t.exclusiveMinimum) ? t.message : "";
|
|
422
|
+
},
|
|
423
|
+
len(e, t) {
|
|
424
|
+
return H(e) || U(e) === Number(t.len) ? "" : t.message;
|
|
425
|
+
},
|
|
426
|
+
pattern(e, t) {
|
|
427
|
+
if (!H(e) && t.pattern) return new RegExp(t.pattern).test(e) ? void 0 : t.message;
|
|
428
|
+
},
|
|
429
|
+
async validator(e, t, n, r) {
|
|
430
|
+
if (s(t.validator)) {
|
|
431
|
+
let a = await Promise.resolve(t.validator(e, t, n, r));
|
|
432
|
+
return i(a) ? a ? "" : t.message : a;
|
|
433
|
+
}
|
|
434
|
+
/* istanbul ignore next */
|
|
435
|
+
throw Error("The rule's validator property must be a function.");
|
|
436
|
+
},
|
|
437
|
+
whitespace(e, t) {
|
|
438
|
+
if (H(e)) return "";
|
|
439
|
+
if (t.whitespace) return /^\s+$/.test(e) ? t.message : "";
|
|
440
|
+
},
|
|
441
|
+
enum(e, t) {
|
|
442
|
+
return H(e) ? "" : m(t.enum).indexOf(e) === -1 ? t.message : "";
|
|
443
|
+
},
|
|
444
|
+
const(e, t) {
|
|
445
|
+
return H(e) || t.const === e ? "" : t.message;
|
|
446
|
+
},
|
|
447
|
+
multipleOf(e, t) {
|
|
448
|
+
return H(e) || Number(e) % Number(t.multipleOf) === 0 ? "" : t.message;
|
|
449
|
+
},
|
|
450
|
+
uniqueItems(e, t) {
|
|
451
|
+
return H(e) ? "" : (e = m(e), e.some((t, n) => {
|
|
452
|
+
for (let r = 0; r < e.length; r++) if (r !== n && !o(e[r], t)) return !1;
|
|
453
|
+
return !0;
|
|
454
|
+
}) ? "" : t.message);
|
|
455
|
+
},
|
|
456
|
+
maxProperties(e, t) {
|
|
457
|
+
return H(e) || Object.keys(e || {}).length <= Number(t.maxProperties) ? "" : t.message;
|
|
458
|
+
},
|
|
459
|
+
minProperties(e, t) {
|
|
460
|
+
return H(e) || Object.keys(e || {}).length >= Number(t.minProperties) ? "" : t.message;
|
|
461
|
+
}
|
|
462
|
+
};
|
|
463
|
+
W(G, {
|
|
464
|
+
maximum: "max",
|
|
465
|
+
minimum: "min",
|
|
466
|
+
maxItems: "max",
|
|
467
|
+
minItems: "min",
|
|
468
|
+
maxLength: "max",
|
|
469
|
+
minLength: "min"
|
|
470
|
+
}), M(G), j(g), N(h);
|
|
471
|
+
async function K(e, t, n) {
|
|
472
|
+
let r = V(t, n), i = {
|
|
473
|
+
error: [],
|
|
474
|
+
success: [],
|
|
475
|
+
warning: []
|
|
476
|
+
};
|
|
477
|
+
for (let t = 0; t < r.length; t++) {
|
|
478
|
+
let a = await r[t](e, n?.context);
|
|
479
|
+
if (!a) continue;
|
|
480
|
+
let { type: o, message: s } = a;
|
|
481
|
+
if (i[o] = i[o] || [], s && (i[o].push(s), n?.validateFirst)) break;
|
|
482
|
+
}
|
|
483
|
+
return i;
|
|
484
|
+
}
|
|
485
|
+
export { E as getLocaleByPath, k as getValidateFormats, T as getValidateLanguage, D as getValidateLocale, C as getValidateLocaleIOSCode, O as getValidateMessageTemplateEngine, A as getValidateRules, I as isValidateResult, V as parseValidator, R as parseValidatorDescription, z as parseValidatorDescriptions, B as parseValidatorRules, N as registerValidateFormats, j as registerValidateLocale, P as registerValidateMessageTemplateEngine, M as registerValidateRules, w as setValidateLanguage, K as validate };
|
|
486
|
+
|
|
487
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":["deepmerge","rules","locales","formats","formats_default","locale_default","getIn","FormPath","self","globalThisPolyfill","defaultLanguage","getBrowserLanguage","registry","getISOCode","isoCode","language","lang","lowerCase","each","target","key","getValidateLocaleIOSCode","setValidateLanguage","getValidateLanguage","getLocaleByPath","path","getValidateLocale","getValidateMessageTemplateEngine","getValidateFormats","getValidateRules","registerValidateLocale","merge","locale","registerValidateRules","rules","isFn","rule","registerValidateFormats","formats","isStr","pattern","registerValidateMessageTemplateEngine","template","render","result","message","$0","isValidateResult","obj","\"type\"","\"message\"","getRuleMessage","type","parseValidatorDescription","description","parseValidatorDescriptions","validator","isArr","parseValidatorRules","getRulesKeys","keys","getContext","context","createValidate","context_","value","results","callback","scope","isBool","buf","parseValidator","triggerType","options","isValidateEmpty","i","isValid","isEmpty","getLength","stringLength","extendSameRules","names","name","args","realName","RULES","format","isNum","response","toArr","index","isEqual","item","validate","validates"],"sources":["../src/formats.ts","../src/locale.ts","../src/registry.ts","../src/template.ts","../src/types.ts","../src/parser.ts","../src/rules.ts","../src/validator.ts"],"sourcesContent":["export default {\n url: new RegExp(\n // protocol identifier\n '^(?:(?:(?:https?|ftp|rtmp):)?//)' +\n // user:pass authentication\n '(?:\\\\S+(?::\\\\S*)?@)?' +\n '(?:' +\n // IP address exclusion - private & local networks\n // Reference: https://www.arin.net/knowledge/address_filters.html\n\n // filter 10.*.*.* and 127.*.*.* addresses\n '(?!(?:10|127)(?:\\\\.\\\\d{1,3}){3})' +\n // filter 169.254.*.* and 192.168.*.*\n '(?!(?:169\\\\.254|192\\\\.168)(?:\\\\.\\\\d{1,3}){2})' +\n // filter 172.16.0.0 - 172.31.255.255\n // TODO: add test to validate that it invalidates address in 16-31 range\n '(?!172\\\\.(?:1[6-9]|2\\\\d|3[0-1])(?:\\\\.\\\\d{1,3}){2})' +\n // IP address dotted notation octets\n // excludes loopback network 0.0.0.0\n // excludes reserved space >= 224.0.0.0\n // excludes network & broadcast addresses\n // (first & last IP address of each class)\n\n // filter 1. part for 1-223\n '(?:22[0-3]|2[01]\\\\d|[1-9]\\\\d?|1\\\\d\\\\d)' +\n // filter 2. and 3. part for 0-255\n '(?:\\\\.(?:25[0-5]|2[0-4]\\\\d|1?\\\\d{1,2})){2}' +\n // filter 4. part for 1-254\n '(?:\\\\.(?:25[0-4]|2[0-4]\\\\d|1\\\\d\\\\d|[1-9]\\\\d?))' +\n '|' +\n // host name\n '(?:(?:[a-z\\\\u00a1-\\\\uffff0-9_]-*)*[a-z\\\\u00a1-\\\\uffff0-9_]+)' +\n // domain name\n '(?:\\\\.(?:[a-z\\\\u00a1-\\\\uffff0-9_]-*)*[a-z\\\\u00a1-\\\\uffff0-9_]+)*' +\n // TLD identifier\n '(?:\\\\.(?:[a-z\\\\u00a1-\\\\uffff_]{2,}))' +\n ')' +\n // port number\n '(?::\\\\d{2,5})?' +\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(((:[0-9A-Fa-f]{1,4}){1,7})|((:[0-9A-Fa-f]{1,4}){0,5}:((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3}))|:)))(%.+)?\\s*$/,\n\n ipv4: /^((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\\.){3}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})$/,\n\n number: /^[+-]?\\d+(\\.\\d+)?$/,\n\n integer: /^[+-]?\\d+$/,\n\n qq: /^(\\+?[1-9]\\d*|0)$/,\n\n phone: /^\\d{3}-\\d{8}$|^\\d{4}-\\d{7}$|^\\d{11}$/,\n\n idcard: /^\\d{15}$|^\\d{17}(\\d|x|X)$/,\n\n money: /^([\\u0024\\u00A2\\u00A3\\u00A4\\u20AC\\u00A5\\u20B1\\u20B9\\uFFE5]\\s*)(\\d+,?)+(\\.\\d+)?\\s*$/,\n\n zh: /^[\\u4e00-\\u9fa5]+$/,\n\n date: /^[0-9]+[./-][0-9]+[./-][0-9]+\\s*(?:[0-9]+\\s*:\\s*[0-9]+\\s*:\\s*[0-9]+)?$/,\n\n zip: /^[0-9]{6}$/,\n}\n","export default {\n en: {\n pattern: 'This field is invalid',\n invalid: 'This field is invalid',\n required: 'The field value is required',\n number: 'The field value is not a number',\n integer: 'The field value is not an integer number',\n url: 'The field value is a invalid url',\n email: 'The field value is not a email format',\n ipv6: 'The field value is not a ipv6 format',\n ipv4: 'The field value is not a ipv4 format',\n idcard: 'The field value is not an idcard format',\n qq: 'The field value is not a qq number format',\n phone: 'The field value is not a phone number format',\n money: 'The field value is not a currency format',\n zh: 'The field value is not a chinese string',\n date: 'The field value is not a valid date format',\n zip: 'The field value is not a zip format',\n len: 'The length or number of entries must be {{len}}',\n min: 'The length or number of entries must be at least {{min}}',\n minLength: 'The length or number of entries must be at least {{minLength}}',\n minItems: 'The length or number of entries must be at least {{minItems}}',\n maximum: 'The field value cannot be greater than {{maximum}}',\n exclusiveMaximum: 'The field value must be less than {{exclusiveMaximum}}',\n minimum: 'The field value cannot be less than {{minimum}}',\n exclusiveMinimum: 'The field value must be greater than {{exclusiveMinimum}}',\n max: 'The field length or number of entries must be at most {{max}}',\n maxLength: 'The field length or number of entries must be at most {{maxLength}}',\n maxItems: 'The field length or number of entries must be at most {{maxItems}}',\n whitespace: 'This field value cannot be blank string.',\n enum: 'The field value must be one of {{enum}}',\n\n const: 'The field value must be equal to {{const}}',\n multipleOf: 'The field value must be divisible by {{multipleOf}}',\n maxProperties: 'The number of field properties cannot be greater than {{maxProperties}}',\n minProperties: 'The number of field properties cannot be less than {{maxProperties}}',\n uniqueItems: 'Array elements are not unique',\n },\n zh: {\n pattern: '该字段不是一个合法的字段',\n invalid: '该字段不是一个合法的字段',\n required: '该字段是必填字段',\n number: '该字段不是合法的数字',\n integer: '该字段不是合法的整型数字',\n url: '该字段不是合法的url',\n email: '该字段不是合法的邮箱格式',\n ipv6: '该字段不是合法的ipv6格式',\n ipv4: '该字段不是合法的ipv4格式',\n idcard: '该字段不是合法的身份证格式',\n qq: '该字段不符合QQ号格式',\n phone: '该字段不是有效的手机号',\n money: '该字段不是有效货币格式',\n zh: '该字段不是合法的中文字符串',\n date: '该字段不是合法的日期格式',\n zip: '该字段不是合法的邮编格式',\n len: '长度或条目数必须为{{len}}',\n min: '长度或条目数不能小于{{min}}',\n minLength: '长度或条目数不能小于{{minLength}}',\n minItems: '长度或条目数不能小于{{minItems}}',\n max: '长度或条目数不能大于{{max}}',\n maxLength: '长度或条目数不能大于{{maxLength}}',\n maxItems: '长度或条目数不能大于{{maxItems}}',\n maximum: '数值不能大于{{maximum}}',\n exclusiveMaximum: '数值必须小于{{exclusiveMaximum}}',\n minimum: '数值不能小于{{minimum}}',\n exclusiveMinimum: '数值必须大于{{exclusiveMinimum}}',\n whitespace: '不能为纯空白字符串',\n enum: '字段值必须为{{enum}}其中一个',\n const: '字段值必须等于{{const}}',\n multipleOf: '字段值不能被{{multipleOf}}整除',\n maxProperties: '字段属性数量不能大于{{maxProperties}}',\n minProperties: '字段属性数量不能小于{{minProperties}}',\n uniqueItems: '数组元素不唯一',\n },\n 'en-US': {\n pattern: 'This field is invalid',\n invalid: 'This field is invalid',\n required: 'The field value is required',\n number: 'The field value is not a number',\n integer: 'The field value is not an integer number',\n url: 'The field value is a invalid url',\n email: 'The field value is not a email format',\n ipv6: 'The field value is not a ipv6 format',\n ipv4: 'The field value is not a ipv4 format',\n idcard: 'The field value is not an idcard format',\n qq: 'The field value is not a qq number format',\n phone: 'The field value is not a phone number format',\n money: 'The field value is not a currency format',\n zh: 'The field value is not a chinese string',\n date: 'The field value is not a valid date format',\n zip: 'The field value is not a zip format',\n len: 'The length or number of entries must be {{len}}',\n min: 'The length or number of entries must be at least {{min}}',\n minLength: 'The length or number of entries must be at least {{minLength}}',\n minItems: 'The length or number of entries must be at least {{minItems}}',\n maximum: 'The field value cannot be greater than {{maximum}}',\n exclusiveMaximum: 'The field value must be less than {{exclusiveMaximum}}',\n minimum: 'The field value cannot be less than {{minimum}}',\n exclusiveMinimum: 'The field value must be greater than {{exclusiveMinimum}}',\n max: 'The field length or number of entries must be at most {{max}}',\n maxLength: 'The field length or number of entries must be at most {{maxLength}}',\n maxItems: 'The field length or number of entries must be at most {{maxItems}}',\n whitespace: 'This field value cannot be blank string.',\n enum: 'The field value must be one of {{enum}}',\n const: 'The field value must be equal to {{const}}',\n multipleOf: 'The field value must be divisible by {{multipleOf}}',\n maxProperties: 'The number of field properties cannot be greater than {{maxProperties}}',\n minProperties: 'The number of field properties cannot be less than {{maxProperties}}',\n uniqueItems: 'Array elements are not unique',\n },\n 'zh-CN': {\n pattern: '该字段不是一个合法的字段',\n invalid: '该字段不是一个合法的字段',\n required: '该字段是必填字段',\n number: '该字段不是合法的数字',\n integer: '该字段不是合法的整型数字',\n url: '该字段不是合法的url',\n email: '该字段不是合法的邮箱格式',\n ipv6: '该字段不是合法的ipv6格式',\n ipv4: '该字段不是合法的ipv4格式',\n idcard: '该字段不是合法的身份证格式',\n qq: '该字段不符合QQ号格式',\n phone: '该字段不是有效的手机号',\n money: '该字段不是有效货币格式',\n zh: '该字段不是合法的中文字符串',\n date: '该字段不是合法的日期格式',\n zip: '该字段不是合法的邮编格式',\n len: '长度或条目数必须为{{len}}',\n min: '长度或条目数不能小于{{min}}',\n minLength: '长度或条目数不能小于{{minLength}}',\n minItems: '长度或条目数不能小于{{minItems}}',\n maxLength: '长度或条目数不能大于{{maxLength}}',\n maxItems: '长度或条目数不能大于{{maxItems}}',\n max: '长度或条目数不能大于{{max}}',\n maximum: '数值不能大于{{maximum}}',\n exclusiveMaximum: '数值必须小于{{exclusiveMaximum}}',\n minimum: '数值不能小于{{minimum}}',\n exclusiveMinimum: '数值必须大于{{exclusiveMinimum}}',\n whitespace: '不能为纯空白字符串',\n enum: '字段值必须为{{enum}}其中一个',\n const: '字段值必须等于{{const}}',\n multipleOf: '字段值不能被{{multipleOf}}整除',\n maxProperties: '字段属性数量不能大于{{maxProperties}}',\n minProperties: '字段属性数量不能小于{{minProperties}}',\n uniqueItems: '数组元素不唯一',\n },\n 'zh-TW': {\n pattern: '該字段不是一個合法的字段',\n invalid: '該字段不是一個合法的字段',\n required: '該字段是必填字段',\n number: '該字段不是合法的數字',\n integer: '該字段不是合法的整型數字',\n url: '該字段不是合法的url',\n email: '該字段不是合法的郵箱格式',\n ipv6: '該字段不是合法的ipv6格式',\n ipv4: '該字段不是合法的ipv4格式',\n idcard: '該字段不是合法的身份證格式',\n qq: '該字段不符合QQ號格式',\n phone: '該字段不是有效的手機號',\n money: '該字段不是有效貨幣格式',\n zh: '該字段不是合法的中文字符串',\n date: '該字段不是合法的日期格式',\n zip: '該字段不是合法的郵編格式',\n len: '長度或條目數必須為{{len}}',\n min: '長度或條目數不能小於{{min}}',\n minItems: '長度或條目數不能小於{{minItems}}',\n minLength: '長度或條目數不能小於{{minLength}}',\n max: '長度或條目數不能大於{{max}}',\n maxItems: '長度或條目數不能大於{{maxItems}}',\n maxLength: '長度或條目數不能大於{{maxLength}}',\n maximum: '數值不能大於{{maximum}}',\n exclusiveMaximum: '數值必須小於{{exclusiveMaximum}}',\n minimum: '數值不能小於{{minimum}}',\n exclusiveMinimum: '數值必須大於{{exclusiveMinimum}}',\n whitespace: '不能為純空白字符串',\n enum: '字段值必須為{{enum}}其中一個',\n const: '字段值必須等於{{const}}',\n multipleOf: '字段值不能被{{multipleOf}}整除',\n maxProperties: '字段屬性數量不能大於{{maxProperties}}',\n minProperties: '字段屬性數量不能小於{{minProperties}}',\n uniqueItems: '數組元素不唯一',\n },\n ja: {\n url: 'このフィールドは無効なURLです',\n whitespace: 'このフィールドを空の文字列にすることはできません。',\n zh: 'このフィールドは中国語の文字列ではありません',\n zip: 'このフィールドはzip形式ではありません',\n date: 'このフィールドは有効な日付形式ではありません',\n email: 'このフィールドはメール形式ではありません',\n exclusiveMaximum: '値は{{exclusiveMaximum}}未満である必要があります',\n exclusiveMinimum: '値は{{exclusiveMinimum}}より大きい必要があります',\n idcard: 'このフィールドはIDカード形式ではありません',\n integer: 'このフィールドは整数ではありません',\n ipv4: 'このフィールドはIPv4形式ではありません',\n ipv6: 'このフィールドはIPv6形式ではありません',\n len: 'エントリの長さまたは数は{{len}}でなければなりません',\n max: 'エントリの長さまたは数は最大{{max}}でなければなりません',\n maxItems: 'エントリの長さまたは数は最大{{maxItems}}でなければなりません',\n maxLength: 'エントリの長さまたは数は最大{{maxLength}}でなければなりません',\n maximum: '値は{{最大}}を超えることはできません',\n min: 'エントリの長さまたは数は、少なくとも{{min}}である必要があります',\n minItems: 'エントリの長さまたは数は、少なくとも{{minItems}}である必要があります',\n minLength: 'エントリの長さまたは数は、少なくとも{{minLength}}である必要があります',\n minimum: '値は{{minimum}}以上にする必要があります',\n money: 'このフィールドは通貨形式ではありません',\n number: 'このフィールドは数値ではありません',\n pattern: 'このフィールドはどのパターンとも一致しません',\n invalid: 'このフィールドはどのパターンとも一致しません',\n phone: 'このフィールドは電話番号の形式ではありません',\n qq: 'このフィールドはqq数値形式ではありません',\n required: 'この項目は必須です',\n enum: 'フィールド値は{{enum}}のいずれかである必要があります',\n cons: 'フィールド値は{{const}}と等しくなければなりません',\n multipleOf: 'フィールド値を{{multipleOf}}で割り切れない',\n maxProperties: 'フィールドプロパティの数は{{maxProperties}}を超えることはできません',\n minProperties: 'フィールドプロパティの数は{{minProperties}}未満にすることはできません',\n uniqueItems: '配列要素は一意ではありません',\n },\n}\n","import { FormPath, merge as deepmerge, each, globalThisPolyfill, isFn, isStr, lowerCase } from '@formvk/shared'\n\nimport type {\n IRegistryFormats,\n IRegistryLocaleMessages,\n IRegistryLocales,\n IRegistryRules,\n ValidatorFunction,\n ValidatorFunctionResponse,\n} from './types'\n\nconst getIn = FormPath.getIn\n\nconst self = globalThisPolyfill\n\nconst defaultLanguage = 'en'\n\nfunction getBrowserLanguage() {\n if (!self.navigator) {\n return defaultLanguage\n }\n return self.navigator.language || defaultLanguage\n}\n\nconst registry: any = {\n locales: {\n messages: {},\n language: getBrowserLanguage(),\n },\n formats: {},\n rules: {},\n template: null,\n}\n\nfunction getISOCode(language: string) {\n let isoCode = registry.locales.language\n if (registry.locales.messages[language]) {\n return language\n }\n const lang = lowerCase(language)\n each(registry.locales.messages, (messages: IRegistryLocaleMessages, key: string) => {\n const target = lowerCase(key)\n if (target.indexOf(lang) > -1 || lang.indexOf(target) > -1) {\n isoCode = key\n return false\n }\n })\n return isoCode\n}\n\nexport const getValidateLocaleIOSCode = getISOCode\n\nexport function setValidateLanguage(lang: string) {\n registry.locales.language = lang || defaultLanguage\n}\n\nexport function getValidateLanguage() {\n return registry.locales.language\n}\n\nexport function getLocaleByPath(path: string, lang: string = registry.locales.language) {\n return getIn(registry.locales.messages, `${getISOCode(lang)}.${path}`)\n}\n\nexport function getValidateLocale(path: string) {\n const message = getLocaleByPath(path)\n return message || getLocaleByPath('pattern') || getLocaleByPath('pattern', defaultLanguage)\n}\n\nexport function getValidateMessageTemplateEngine() {\n return registry.template\n}\n\nexport function getValidateFormats(key?: string) {\n return key ? registry.formats[key] : registry.formats\n}\n\nexport function getValidateRules<T>(\n key?: T\n): T extends string ? ValidatorFunction : { [key: string]: ValidatorFunction } {\n return key ? registry.rules[key as any] : registry.rules\n}\n\nexport function registerValidateLocale(locale: IRegistryLocales) {\n registry.locales.messages = deepmerge(registry.locales.messages, locale)\n}\n\nexport function registerValidateRules(rules: IRegistryRules) {\n each(rules, (rule, key) => {\n if (isFn(rule)) {\n registry.rules[key] = rule\n }\n })\n}\n\nexport function registerValidateFormats(formats: IRegistryFormats) {\n each(formats, (pattern, key) => {\n if (isStr(pattern) || pattern instanceof RegExp) {\n registry.formats[key] = new RegExp(pattern)\n }\n })\n}\n\nexport function registerValidateMessageTemplateEngine(\n template: (message: ValidatorFunctionResponse, context: any) => any\n) {\n registry.template = template\n}\n","import { FormPath, isFn, isStr } from '@formvk/shared'\n\nimport { getValidateMessageTemplateEngine } from './registry'\nimport type { IValidateResult, IValidatorRules } from './types'\n\nexport function render(result: IValidateResult, rules: IValidatorRules): IValidateResult {\n const { message } = result\n if (isStr(message)) {\n const template = getValidateMessageTemplateEngine()\n if (isFn(template)) {\n result.message = template(message, rules)\n }\n result.message = result.message.replace(/\\{\\{\\s*([\\w.]+)\\s*\\}\\}/g, (_, $0) => {\n return FormPath.getIn(rules, $0)\n })\n }\n return result\n}\n","export type ValidatorFormats =\n | 'url'\n | 'email'\n | 'ipv6'\n | 'ipv4'\n | 'number'\n | 'integer'\n | 'idcard'\n | 'qq'\n | 'phone'\n | 'money'\n | 'zh'\n | 'date'\n | 'zip'\n | (string & {})\n\nexport interface IValidateResult {\n type: 'error' | 'warning' | 'success' | (string & {})\n message: string\n}\n\nexport interface IValidateResults {\n error?: string[]\n warning?: string[]\n success?: string[]\n}\n\nexport function isValidateResult(obj: any): obj is IValidateResult {\n return !!obj['type'] && !!obj['message']\n}\n\nexport type ValidatorFunctionResponse = string | boolean | IValidateResult | undefined | null\n\nexport type ValidatorFunction<Context = any> = (\n value: any,\n rule: IValidatorRules<Context>,\n ctx: Context,\n render: (message: string, scope?: any) => string\n) => ValidatorFunctionResponse | Promise<ValidatorFunctionResponse>\n\nexport type ValidatorParsedFunction<Context = any> = (\n value: any,\n ctx?: Context\n) => IValidateResult | Promise<IValidateResult> | null\n\nexport type ValidatorTriggerType = 'onInput' | 'onFocus' | 'onBlur' | (string & {})\n\nexport interface IValidatorRules<Context = any> {\n triggerType?: ValidatorTriggerType\n format?: ValidatorFormats\n validator?: ValidatorFunction<Context>\n required?: boolean\n pattern?: RegExp | string\n max?: number\n maximum?: number\n maxItems?: number\n minItems?: number\n maxLength?: number\n minLength?: number\n exclusiveMaximum?: number\n exclusiveMinimum?: number\n minimum?: number\n min?: number\n len?: number\n whitespace?: boolean\n enum?: any[]\n const?: any\n multipleOf?: number\n uniqueItems?: boolean\n maxProperties?: number\n minProperties?: number\n message?: string\n [key: string]: any\n}\n\nexport interface IRegistryLocaleMessages {\n [key: string]: string | IRegistryLocaleMessages\n}\n\nexport interface IRegistryLocales {\n [language: string]: IRegistryLocaleMessages\n}\n\nexport interface IRegistryRules<Context = any> {\n [key: string]: ValidatorFunction<Context>\n}\n\nexport interface IRegistryFormats {\n [key: string]: string | RegExp\n}\n\nexport type ValidatorDescription<Context = any> =\n | ValidatorFormats\n | ValidatorFunction<Context>\n | IValidatorRules<Context>\n\nexport type MultiValidator<Context = any> = ValidatorDescription<Context>[]\n\nexport type Validator<Context = any> = ValidatorDescription<Context> | MultiValidator<Context>\n\nexport interface IValidatorOptions<Context = any> {\n validateFirst?: boolean\n triggerType?: ValidatorTriggerType\n context?: Context\n}\n","import { isArr, isBool, isFn, isStr } from '@formvk/shared'\n\nimport { getValidateLocale, getValidateRules } from './registry'\nimport { render } from './template'\nimport type {\n IValidatorOptions,\n IValidatorRules,\n Validator,\n ValidatorDescription,\n ValidatorFunction,\n ValidatorParsedFunction,\n} from './types'\nimport { isValidateResult } from './types'\n\nfunction getRuleMessage(rule: IValidatorRules, type: string) {\n if (rule.format) {\n return rule.message || getValidateLocale(rule.format)\n }\n return rule.message || getValidateLocale(type)\n}\n\nexport function parseValidatorDescription(description: ValidatorDescription): IValidatorRules {\n if (!description) return {}\n let rules: IValidatorRules = {}\n if (isStr(description)) {\n rules.format = description\n } else if (isFn(description)) {\n rules.validator = description\n } else {\n rules = Object.assign(rules, description)\n }\n return rules\n}\n\nexport function parseValidatorDescriptions<Context = any>(validator?: Validator<Context>): IValidatorRules[] {\n if (!validator) return []\n const array = isArr(validator) ? validator : [validator]\n return array.map(description => {\n return parseValidatorDescription(description)\n })\n}\n\nexport function parseValidatorRules(rules: IValidatorRules = {}): ValidatorParsedFunction[] {\n function getRulesKeys(): string[] {\n const keys: any[] = []\n if ('required' in rules) {\n keys.push('required')\n }\n for (const key in rules) {\n if (key === 'required' || key === 'validator') continue\n keys.push(key)\n }\n if ('validator' in rules) {\n keys.push('validator')\n }\n return keys\n }\n function getContext(context: any, value: any) {\n return {\n ...rules,\n ...context,\n value,\n }\n }\n function createValidate(callback: ValidatorFunction, message: string): ValidatorParsedFunction {\n return async (value, context) => {\n const context_ = getContext(context, value)\n try {\n const results = await callback(value, { ...rules, message }, context_, (message: string, scope: any) => {\n return render(\n {\n type: 'error',\n message,\n },\n Object.assign(context_, scope)\n )?.message\n })\n if (isBool(results)) {\n if (!results) {\n return render(\n {\n type: 'error',\n message,\n },\n context_\n )\n }\n return {\n type: 'error',\n message: undefined as unknown as string,\n }\n } else if (results) {\n if (isValidateResult(results)) {\n return render(results, context_)\n }\n return render(\n {\n type: 'error',\n message: results,\n },\n context_\n )\n }\n\n return {\n type: 'error',\n message: undefined as unknown as string,\n }\n } catch (e) {\n return {\n type: 'error',\n message: ((e as Error)?.message || e) as string,\n }\n }\n }\n }\n return getRulesKeys().reduce<ValidatorParsedFunction[]>((buf, key) => {\n const callback = getValidateRules(key)\n if (callback) {\n const validator = createValidate(callback, getRuleMessage(rules, key))\n return buf.concat(validator)\n }\n return buf\n }, [])\n}\n\nexport function parseValidator<Context = any>(validator?: Validator<Context>, options: IValidatorOptions = {}) {\n if (!validator) return []\n const array = isArr(validator) ? validator : [validator]\n return array.reduce<ValidatorParsedFunction<Context>[]>((buf, description) => {\n const rules = parseValidatorDescription(description)\n const triggerType = rules.triggerType ?? 'onInput'\n if (options?.triggerType && options.triggerType !== triggerType) return buf\n return rules ? buf.concat(parseValidatorRules(rules)) : buf\n }, [])\n}\n","import { each, isArr, isBool, isEmpty, isEqual, isFn, isNum, isStr, isValid, stringLength, toArr } from '@formvk/shared'\n\nimport { getValidateFormats } from './registry'\nimport type { IRegistryRules } from './types'\n\nfunction isValidateEmpty(value: any) {\n if (isArr(value)) {\n for (let i = 0; i < value.length; i++) {\n if (isValid(value[i])) return false\n }\n return true\n } else {\n //compat to draft-js\n if (value?.getCurrentContent) {\n /* istanbul ignore next */\n return !value.getCurrentContent()?.hasText()\n }\n return isEmpty(value)\n }\n}\n\nfunction getLength(value: any) {\n return isStr(value) ? stringLength(value) : value ? value.length : 0\n}\n\nfunction extendSameRules(rules: IRegistryRules, names: Record<string, string>) {\n each(names, (realName, name) => {\n rules[name] = (value, rule, ...args) => rules[realName](value, { ...rule, [realName]: rule[name] }, ...args)\n })\n}\n\nconst RULES: IRegistryRules = {\n format(value, rule) {\n if (isValidateEmpty(value)) return ''\n if (rule.format) {\n const format = getValidateFormats(rule.format)\n if (format) {\n return !new RegExp(format).test(value) ? rule.message : ''\n }\n }\n return ''\n },\n required(value, rule) {\n if (rule.required === false) return ''\n return isValidateEmpty(value) ? rule.message : ''\n },\n max(value, rule) {\n if (isValidateEmpty(value)) return ''\n const length = isNum(value) ? value : getLength(value)\n const max = Number(rule.max)\n return length > max ? rule.message : ''\n },\n min(value, rule) {\n if (isValidateEmpty(value)) return ''\n const length = isNum(value) ? value : getLength(value)\n const min = Number(rule.min)\n return length < min ? rule.message : ''\n },\n exclusiveMaximum(value, rule) {\n if (isValidateEmpty(value)) return ''\n const length = isNum(value) ? value : getLength(value)\n const max = Number(rule.exclusiveMaximum)\n return length >= max ? rule.message : ''\n },\n exclusiveMinimum(value, rule) {\n if (isValidateEmpty(value)) return ''\n const length = isNum(value) ? value : getLength(value)\n const min = Number(rule.exclusiveMinimum)\n return length <= min ? rule.message : ''\n },\n len(value, rule) {\n if (isValidateEmpty(value)) return ''\n const length = getLength(value)\n const len = Number(rule.len)\n return length !== len ? rule.message : ''\n },\n\n pattern(value, rule) {\n if (isValidateEmpty(value)) return\n if (!rule.pattern) return\n return !new RegExp(rule.pattern).test(value) ? rule.message : undefined\n },\n async validator(value, rule, context, format) {\n if (isFn(rule.validator)) {\n const response = await Promise.resolve(rule.validator(value, rule, context, format))\n if (isBool(response)) {\n return !response ? rule.message : ''\n } else {\n return response\n }\n }\n /* istanbul ignore next */\n throw new Error(\"The rule's validator property must be a function.\")\n },\n whitespace(value, rule) {\n if (isValidateEmpty(value)) return ''\n if (rule.whitespace) {\n return /^\\s+$/.test(value) ? rule.message : ''\n }\n },\n enum(value, rule) {\n if (isValidateEmpty(value)) return ''\n const enums = toArr(rule.enum)\n return enums.indexOf(value) === -1 ? rule.message : ''\n },\n const(value, rule) {\n if (isValidateEmpty(value)) return ''\n return rule.const !== value ? rule.message : ''\n },\n multipleOf(value, rule) {\n if (isValidateEmpty(value)) return ''\n return Number(value) % Number(rule.multipleOf) !== 0 ? rule.message : ''\n },\n uniqueItems(value, rule) {\n if (isValidateEmpty(value)) return ''\n value = toArr(value)\n return value.some((item: any, index: number) => {\n for (let i = 0; i < value.length; i++) {\n if (i !== index && !isEqual(value[i], item)) {\n return false\n }\n }\n return true\n })\n ? ''\n : rule.message\n },\n maxProperties(value, rule) {\n if (isValidateEmpty(value)) return ''\n return Object.keys(value || {}).length <= Number(rule.maxProperties) ? '' : rule.message\n },\n minProperties(value, rule) {\n if (isValidateEmpty(value)) return ''\n return Object.keys(value || {}).length >= Number(rule.minProperties) ? '' : rule.message\n },\n}\n\nextendSameRules(RULES, {\n maximum: 'max',\n minimum: 'min',\n maxItems: 'max',\n minItems: 'min',\n maxLength: 'max',\n minLength: 'min',\n})\n\nexport default RULES\n","import formats from './formats'\nimport locales from './locale'\nimport { parseValidator } from './parser'\nimport { registerValidateFormats, registerValidateLocale, registerValidateRules } from './registry'\nimport rules from './rules'\nimport type { IValidateResults, IValidatorOptions, Validator } from './types'\n\nregisterValidateRules(rules)\n\nregisterValidateLocale(locales)\n\nregisterValidateFormats(formats)\n\nexport async function validate<Context = any>(\n value: any,\n validator?: Validator<Context>,\n options?: IValidatorOptions<Context>\n): Promise<IValidateResults> {\n const validates = parseValidator(validator, options)\n const results: Record<string, string[]> = {\n error: [],\n success: [],\n warning: [],\n }\n for (let i = 0; i < validates.length; i++) {\n const result = await validates[i](value, options?.context)\n if (!result) continue\n const { type, message } = result\n results[type] = results[type] || []\n if (message) {\n results[type].push(message)\n if (options?.validateFirst) break\n }\n }\n return results\n}\n"],"mappings":";;AAAA,IAAAI,IAAe;CACb,KAAK,gBAAI,OAEP,kfAsCF;CACA,OAAO;CAEP,MAAM;CAEN,MAAM;CAEN,QAAQ;CAER,SAAS;CAET,IAAI;CAEJ,OAAO;CAEP,QAAQ;CAER,OAAO;CAEP,IAAI;CAEJ,MAAM;CAEN,KAAK;AACP,GCjEAC,IAAe;CACb,IAAI;EACF,SAAS;EACT,SAAS;EACT,UAAU;EACV,QAAQ;EACR,SAAS;EACT,KAAK;EACL,OAAO;EACP,MAAM;EACN,MAAM;EACN,QAAQ;EACR,IAAI;EACJ,OAAO;EACP,OAAO;EACP,IAAI;EACJ,MAAM;EACN,KAAK;EACL,KAAK;EACL,KAAK;EACL,WAAW;EACX,UAAU;EACV,SAAS;EACT,kBAAkB;EAClB,SAAS;EACT,kBAAkB;EAClB,KAAK;EACL,WAAW;EACX,UAAU;EACV,YAAY;EACZ,MAAM;EAEN,OAAO;EACP,YAAY;EACZ,eAAe;EACf,eAAe;EACf,aAAa;CACf;CACA,IAAI;EACF,SAAS;E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AAK,IAAIS,IAAI,GAAGA,IAAImB,EAAU,QAAQ,KAAK;EACzC,IAAMlD,IAAS,MAAMkD,EAAUnB,EAAE,CAACV,GAAOQ,GAAS,OAAO;EACzD,IAAI,CAAC7B,GAAQ;EACb,IAAM,EAAE,SAAM,eAAYA;EAE1B,IADA,EAAQQ,KAAQc,EAAQd,MAAS,CAAC,GAC9BP,MACFqB,EAAQd,EAAK,CAAC,KAAKP,CAAO,GACtB4B,GAAS,gBAAe;CAEhC;CACA,OAAOP;AACT"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,23 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@formvk/validator",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"license": "MIT",
|
|
5
|
+
"files": [
|
|
6
|
+
"dist",
|
|
7
|
+
"CHANGELOG.md"
|
|
8
|
+
],
|
|
9
|
+
"type": "module",
|
|
10
|
+
"main": "dist/index.js",
|
|
11
|
+
"module": "dist/index.js",
|
|
12
|
+
"types": "dist/index.d.ts",
|
|
13
|
+
"publishConfig": {
|
|
14
|
+
"access": "public"
|
|
15
|
+
},
|
|
16
|
+
"dependencies": {
|
|
17
|
+
"@formvk/shared": "~1.0.0"
|
|
18
|
+
},
|
|
19
|
+
"scripts": {
|
|
20
|
+
"build": "tsc --noEmit && vite build",
|
|
21
|
+
"test": "vitest"
|
|
22
|
+
}
|
|
6
23
|
}
|