feat: 封装手机号校验,mobile 非必填校验,mobileRequired 必填校验
This commit is contained in:
@@ -110,7 +110,9 @@ const shouldRequired = computed(() => {
|
||||
}
|
||||
|
||||
if (isString(currentRules.value)) {
|
||||
return ['required', 'selectRequired'].includes(currentRules.value);
|
||||
return ['mobileRequired', 'required', 'selectRequired'].includes(
|
||||
currentRules.value,
|
||||
);
|
||||
}
|
||||
|
||||
let isOptional = currentRules?.value?.isOptional?.();
|
||||
|
||||
@@ -68,6 +68,8 @@ export type FormActions = FormContext<GenericObject>;
|
||||
export type CustomRenderType = (() => Component | string) | string;
|
||||
|
||||
export type FormSchemaRuleType =
|
||||
| 'mobile'
|
||||
| 'mobileRequired'
|
||||
| 'required'
|
||||
| 'selectRequired'
|
||||
| null
|
||||
@@ -428,6 +430,16 @@ export interface VbenFormAdapterOptions<
|
||||
modelPropNameMap?: Partial<Record<T, string>>;
|
||||
};
|
||||
defineRules?: {
|
||||
mobile?: (
|
||||
value: any,
|
||||
params: any,
|
||||
ctx: Record<string, any>,
|
||||
) => boolean | string;
|
||||
mobileRequired?: (
|
||||
value: any,
|
||||
params: any,
|
||||
ctx: Record<string, any>,
|
||||
) => boolean | string;
|
||||
required?: (
|
||||
value: any,
|
||||
params: any,
|
||||
|
||||
Reference in New Issue
Block a user