I'm facing an issue with the yup validation library in my Next TS project. The error revolves around the type property under the PostWithSig object in my validation schema. I'm unsure of the root cause, but one possibility could be the name type
itself.
The error message I'm seeing is:
(property) BaseSchema<any, any, any>.type: string Type 'RequiredStringSchema<string | undefined, AnyObject>' is not assignable to type 'string'.ts(2322) schema.d.ts(53, 14): The expected type comes from property 'type' declared here on type 'AnySchema<any, any, any>'
Here is my validation schema:
data: object().shape({
createPostTypedData: object().shape({
id: string().required(),
expiresAt: date().required(),
typedData: object().shape({
types: object().shape({
PostWithSig: array().of({
name: string().required(),
type: string().required(),
}),
}),
domain: object().shape({
name: string().required(),
chainId: number().required(),
version: string().required(),
verifyingContract: string().required(),
}),
value: object().shape({
nonce: number().required(),
deadline: number().required(),
profileId: string().required(),
contentURI: string().required(),
collectModule: string().required(),
collectModuleInitData: string().required(),
referenceModule: string().required(),
referenceModuleInitData: string().required(),
}),
}),
}),
}),
If anyone can shed light on why this error is occurring and suggest a solution, it would be greatly appreciated.