1234567891011121314151617181920212223242526272829303132333435363738 |
- import type {
- VbenFormSchema as FormSchema,
- VbenFormProps,
- } from '@vben/common-ui';
- import type { ComponentType } from './component';
- import { setupVbenForm, useVbenForm as useForm, z } from '@vben/common-ui';
- import { $t } from '@vben/locales';
- setupVbenForm<ComponentType>({
- config: {
- modelPropNameMap: {
- Upload: 'fileList',
- },
- },
- defineRules: {
- required: (value, _params, ctx) => {
- if (value === undefined || value === null || value.length === 0) {
- return $t('ui.formRules.required', [ctx.label]);
- }
- return true;
- },
- selectRequired: (value, _params, ctx) => {
- if (value === undefined || value === null) {
- return $t('ui.formRules.selectRequired', [ctx.label]);
- }
- return true;
- },
- },
- });
- const useVbenForm = useForm<ComponentType>;
- export { useVbenForm, z };
- export type VbenFormSchema = FormSchema<ComponentType>;
- export type { VbenFormProps };
|