Open MshHooman opened 8 months ago
Describe the bug Hi, I'm using ajvResolver in my project but face a typescript error that is wrong.
here is my packages:
"@hookform/resolvers": "3.3.4", "react-hook-form": "^7.0.0", "typescript": "~5.2.2", "vite": "^5.0.0", "@types/react": "^18.2.46", "@types/react-dom": "^18.2.18",
and this is an example of code that I used:
const schema = { type: 'object', properties: { password1: { type: 'string', minLength: 3, errorMessage: { minLength: 'password1 field is required' }, }, password2: { type: 'string', minLength: 3, errorMessage: { minLength: 'password2 field is required' }, }, }, required: ['password1', 'password2'], additionalProperties: false, }; const validation = ajvResolver(schema);
but I face this error from ajvResolver:
ajvResolver
Property 'oneOf' is missing in type '{ type: string; properties: { password1: { type: string; minLength: number; errorMessage: { minLength: string; }; }; password2: { type: string; minLength: number; errorMessage: { minLength: string; }; }; }; required: string[]; additionalProperties: boolean; }' but required in type '{ oneOf: readonly UncheckedJSONSchemaType<FormType, false>[]; }'.ts(2345)
so when I add oneOf property the type problem will be solved but as I understand and test in AJV directly ,this property is not required !
oneOf
AJV
also getting this issue
Can you try assigning the type JSONSchemaType to your schema as mentioned here. It solved the issue for me.
JSONSchemaType
Can you please provide a minimal reproducible example (e.g. a Codesandbox)?
Describe the bug Hi, I'm using ajvResolver in my project but face a typescript error that is wrong.
here is my packages:
and this is an example of code that I used:
but I face this error from
ajvResolver
:Property 'oneOf' is missing in type '{ type: string; properties: { password1: { type: string; minLength: number; errorMessage: { minLength: string; }; }; password2: { type: string; minLength: number; errorMessage: { minLength: string; }; }; }; required: string[]; additionalProperties: boolean; }' but required in type '{ oneOf: readonly UncheckedJSONSchemaType<FormType, false>[]; }'.ts(2345)
so when I add
oneOf
property the type problem will be solved but as I understand and test inAJV
directly ,this property is not required !