feat: naive adapter form
This commit is contained in:
@@ -7,6 +7,7 @@ import type { ComponentType } from './component';
|
|||||||
|
|
||||||
import { setupVbenForm, useVbenForm as useForm, z } from '@vben/common-ui';
|
import { setupVbenForm, useVbenForm as useForm, z } from '@vben/common-ui';
|
||||||
import { $t } from '@vben/locales';
|
import { $t } from '@vben/locales';
|
||||||
|
import { isMobile } from '@vben/utils';
|
||||||
|
|
||||||
async function initSetupVbenForm() {
|
async function initSetupVbenForm() {
|
||||||
setupVbenForm<ComponentType>({
|
setupVbenForm<ComponentType>({
|
||||||
@@ -33,6 +34,25 @@ async function initSetupVbenForm() {
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
|
// 手机号非必填
|
||||||
|
mobile: (value, _params, ctx) => {
|
||||||
|
if (value === undefined || value === null || value.length === 0) {
|
||||||
|
return true;
|
||||||
|
} else if (!isMobile(value)) {
|
||||||
|
return $t('ui.formRules.mobile', [ctx.label]);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
},
|
||||||
|
// 手机号必填
|
||||||
|
mobileRequired: (value, _params, ctx) => {
|
||||||
|
if (value === undefined || value === null || value.length === 0) {
|
||||||
|
return $t('ui.formRules.required', [ctx.label]);
|
||||||
|
}
|
||||||
|
if (!isMobile(value)) {
|
||||||
|
return $t('ui.formRules.mobile', [ctx.label]);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user