@lytjs/plugin-validation 6.9.2 → 6.9.3
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/dist/index.d.cts +51 -0
- package/dist/index.d.ts +51 -0
- package/package.json +4 -4
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import * as _lytjs_core from '@lytjs/core';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @lytjs/plugin-validation - 类型定义
|
|
5
|
+
*/
|
|
6
|
+
type ValidationRuleType = 'required' | 'email' | 'phone' | 'number' | 'min' | 'max' | 'minLength' | 'maxLength' | 'length' | 'pattern' | 'url' | 'uuid' | 'date' | 'custom';
|
|
7
|
+
interface ValidationRule {
|
|
8
|
+
type: ValidationRuleType;
|
|
9
|
+
message?: string;
|
|
10
|
+
value?: unknown;
|
|
11
|
+
validator?: (value: unknown, allValues?: Record<string, unknown>) => boolean | Promise<boolean>;
|
|
12
|
+
}
|
|
13
|
+
interface Validator {
|
|
14
|
+
(value: unknown, ruleValue?: unknown, allValues?: Record<string, unknown>): boolean | Promise<boolean>;
|
|
15
|
+
}
|
|
16
|
+
interface ValidationResult {
|
|
17
|
+
valid: boolean;
|
|
18
|
+
errors: string[];
|
|
19
|
+
}
|
|
20
|
+
interface FieldValidationConfig {
|
|
21
|
+
rules: ValidationRule[];
|
|
22
|
+
label?: string;
|
|
23
|
+
}
|
|
24
|
+
interface ValidationSchema {
|
|
25
|
+
[field: string]: FieldValidationConfig;
|
|
26
|
+
}
|
|
27
|
+
interface ValidationMessages {
|
|
28
|
+
[key: string]: string | ((value?: unknown, label?: string) => string);
|
|
29
|
+
}
|
|
30
|
+
interface ValidationOptions {
|
|
31
|
+
messages?: ValidationMessages;
|
|
32
|
+
validateOnChange?: boolean;
|
|
33
|
+
validateOnBlur?: boolean;
|
|
34
|
+
stopOnFirstError?: boolean;
|
|
35
|
+
}
|
|
36
|
+
interface ValidationInstance {
|
|
37
|
+
validate: (schema: ValidationSchema, values: Record<string, unknown>) => Promise<ValidationResult>;
|
|
38
|
+
validateField: (field: string, value: unknown, rules: ValidationRule[], allValues?: Record<string, unknown>) => Promise<ValidationResult>;
|
|
39
|
+
setMessages: (messages: ValidationMessages) => void;
|
|
40
|
+
addRule: (type: ValidationRuleType, validator: Validator, defaultMessage?: string) => void;
|
|
41
|
+
}
|
|
42
|
+
interface ValidationPluginOptions extends ValidationOptions {
|
|
43
|
+
name?: string;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
declare const defaultMessages: ValidationMessages;
|
|
47
|
+
|
|
48
|
+
declare function createValidationInstance(options?: ValidationPluginOptions): ValidationInstance;
|
|
49
|
+
declare const pluginValidation: _lytjs_core.PluginDefinition<unknown>;
|
|
50
|
+
|
|
51
|
+
export { type FieldValidationConfig, type ValidationInstance, type ValidationMessages, type ValidationOptions, type ValidationPluginOptions, type ValidationResult, type ValidationRule, type ValidationRuleType, type ValidationSchema, type Validator, createValidationInstance, pluginValidation as default, defaultMessages };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import * as _lytjs_core from '@lytjs/core';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @lytjs/plugin-validation - 类型定义
|
|
5
|
+
*/
|
|
6
|
+
type ValidationRuleType = 'required' | 'email' | 'phone' | 'number' | 'min' | 'max' | 'minLength' | 'maxLength' | 'length' | 'pattern' | 'url' | 'uuid' | 'date' | 'custom';
|
|
7
|
+
interface ValidationRule {
|
|
8
|
+
type: ValidationRuleType;
|
|
9
|
+
message?: string;
|
|
10
|
+
value?: unknown;
|
|
11
|
+
validator?: (value: unknown, allValues?: Record<string, unknown>) => boolean | Promise<boolean>;
|
|
12
|
+
}
|
|
13
|
+
interface Validator {
|
|
14
|
+
(value: unknown, ruleValue?: unknown, allValues?: Record<string, unknown>): boolean | Promise<boolean>;
|
|
15
|
+
}
|
|
16
|
+
interface ValidationResult {
|
|
17
|
+
valid: boolean;
|
|
18
|
+
errors: string[];
|
|
19
|
+
}
|
|
20
|
+
interface FieldValidationConfig {
|
|
21
|
+
rules: ValidationRule[];
|
|
22
|
+
label?: string;
|
|
23
|
+
}
|
|
24
|
+
interface ValidationSchema {
|
|
25
|
+
[field: string]: FieldValidationConfig;
|
|
26
|
+
}
|
|
27
|
+
interface ValidationMessages {
|
|
28
|
+
[key: string]: string | ((value?: unknown, label?: string) => string);
|
|
29
|
+
}
|
|
30
|
+
interface ValidationOptions {
|
|
31
|
+
messages?: ValidationMessages;
|
|
32
|
+
validateOnChange?: boolean;
|
|
33
|
+
validateOnBlur?: boolean;
|
|
34
|
+
stopOnFirstError?: boolean;
|
|
35
|
+
}
|
|
36
|
+
interface ValidationInstance {
|
|
37
|
+
validate: (schema: ValidationSchema, values: Record<string, unknown>) => Promise<ValidationResult>;
|
|
38
|
+
validateField: (field: string, value: unknown, rules: ValidationRule[], allValues?: Record<string, unknown>) => Promise<ValidationResult>;
|
|
39
|
+
setMessages: (messages: ValidationMessages) => void;
|
|
40
|
+
addRule: (type: ValidationRuleType, validator: Validator, defaultMessage?: string) => void;
|
|
41
|
+
}
|
|
42
|
+
interface ValidationPluginOptions extends ValidationOptions {
|
|
43
|
+
name?: string;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
declare const defaultMessages: ValidationMessages;
|
|
47
|
+
|
|
48
|
+
declare function createValidationInstance(options?: ValidationPluginOptions): ValidationInstance;
|
|
49
|
+
declare const pluginValidation: _lytjs_core.PluginDefinition<unknown>;
|
|
50
|
+
|
|
51
|
+
export { type FieldValidationConfig, type ValidationInstance, type ValidationMessages, type ValidationOptions, type ValidationPluginOptions, type ValidationResult, type ValidationRule, type ValidationRuleType, type ValidationSchema, type Validator, createValidationInstance, pluginValidation as default, defaultMessages };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lytjs/plugin-validation",
|
|
3
|
-
"version": "6.9.
|
|
3
|
+
"version": "6.9.3",
|
|
4
4
|
"description": "LytJS official validation plugin for type-safe form validation",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
@@ -29,9 +29,9 @@
|
|
|
29
29
|
"clean": "rm -rf dist"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@lytjs/core": "
|
|
33
|
-
"@lytjs/reactivity": "
|
|
34
|
-
"@lytjs/plugin-form": "
|
|
32
|
+
"@lytjs/core": "^6.9.3",
|
|
33
|
+
"@lytjs/reactivity": "^6.9.3",
|
|
34
|
+
"@lytjs/plugin-form": "^6.9.3"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
37
|
"tsup": "^8.0.0",
|