Skip to content

Commit 290bb16

Browse files
remonkelogaretm
andauthored
feat(nuxt): added typedSchemaPackage option to resolve conflicts (#4544)
* fix(nuxt): added typedSchemaPackage option to resolve conficts * fix: apply suggested refactor --------- Co-authored-by: Abdelrahman Awad <[email protected]>
1 parent bbecc97 commit 290bb16

File tree

1 file changed

+27
-3
lines changed

1 file changed

+27
-3
lines changed

packages/nuxt/src/module.ts

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,12 @@ import type { NuxtModule } from '@nuxt/schema';
33
import { isPackageExists } from 'local-pkg';
44

55
type ComponentName = 'Field' | 'Form' | 'ErrorMessage' | 'FieldArray';
6+
type TypedSchemaPackage = 'yup' | 'zod' | 'valibot' | 'none';
7+
68
export interface VeeValidateNuxtOptions {
79
autoImports?: boolean;
810
componentNames?: Partial<Record<ComponentName, string>>;
11+
typedSchemaPackage?: TypedSchemaPackage;
912
}
1013

1114
const components: ComponentName[] = ['Field', 'Form', 'ErrorMessage', 'FieldArray'];
@@ -67,9 +70,30 @@ export default defineNuxtModule<VeeValidateNuxtOptions>({
6770
});
6871
}
6972

70-
checkForYup(options);
71-
checkForZod(options);
72-
checkForValibot(options);
73+
if (options.typedSchemaPackage === 'none') {
74+
return;
75+
}
76+
77+
if (options.typedSchemaPackage === 'yup') {
78+
checkForYup(options);
79+
return;
80+
}
81+
82+
if (options.typedSchemaPackage === 'zod') {
83+
checkForZod(options);
84+
return;
85+
}
86+
87+
if (options.typedSchemaPackage === 'valibot') {
88+
checkForValibot(options);
89+
return;
90+
}
91+
92+
if (!checkForYup(options)) {
93+
if (!checkForZod(options)) {
94+
checkForValibot(options);
95+
}
96+
}
7397
},
7498
}) as NuxtModule<VeeValidateNuxtOptions>;
7599

0 commit comments

Comments
 (0)