FormKit的官方验证包/插件。阅读验证文档以获取使用说明。
给定一个节点,返回应在验证消息中使用的名称。这可以是validationLabel
属性、label
属性或输入的名称(按顺序)。
createMessageName(node: FormKitNode): string;
node
— 要显示的节点实际的验证插件函数。必须在此处进行所有的引导。
createValidationPlugin(baseRules?: FormKitValidationRules): (node: FormKitNode) => void;
baseRules
可选 — 要包含在插件中的基本验证规则。默认情况下,FormKit通过defaultConfig提供了@formkit/rules包中的所有规则。从给定的节点及其所有后代中提取所有验证消息。这不是响应式的,必须在每次消息更改时重新调用。
getValidationMessages(node: FormKitNode): Map<FormKitNode, FormKitMessage[]>;
node
— 要从中提取验证规则的FormKit节点及其后代。影响验证应用方式的特殊验证属性。
interface FormKitValidationHints {
blocking: boolean;
debounce: number;
force: boolean;
name: string;
skipEmpty: boolean;
}
本地化验证消息注册表的接口。
interface FormKitValidationMessages {
[index: string]: string | ((...args: FormKitValidationI18NArgs) => string);
}
FormKit验证规则结构化为一个键/函数对的对象,其中对象的键是验证规则名称。
interface FormKitValidationRules {
[index: string]: FormKitValidationRule;
}
定义完全解析的验证规则的样式。
type FormKitValidation = {
rule: FormKitValidationRule;
args: any[];
timer: number;
state: boolean | null;
queued: boolean;
deps: FormKitDependencies;
messageObserver?: FormKitObservedNode;
} & FormKitValidationHints;
传递给i18n插件中的验证消息的参数。
type FormKitValidationI18NArgs = [
{
node: FormKitNode;
name: string;
args: any[];
message?: string;
}
];
定义解析验证规则的样式,但尚未必定替换验证规则。
type FormKitValidationIntent = [string | FormKitValidationRule, ...any[]];
通用验证规则的签名。它接受一个输入(通常是字符串),但应能够接受任何输入类型,并返回一个布尔值,指示是否通过了验证。
type FormKitValidationRule = {
(node: FormKitNode, ...args: any[]): boolean | Promise<boolean>;
ruleName?: string;
} & Partial<FormKitValidationHints>;