I am currently working on creating a Joi schema validation for the following structure:
type Toy = {
id: string;
codeName: (nameFormat?: string) => string;
price: number;
}
The issue I am facing is with validating the codeName
field.
I am unsure of how to specify that the codeName
is a function with an optional parameter of type string that returns a string.
Additionally, the codeName field must be mandatory.
I have searched through documentation but haven't found a satisfactory solution. There are also no relevant threads on Stack Overflow or other platforms.
The project I am working on is using Joi version 14 Any assistance you can provide would be greatly appreciated.
To give you an idea of what I am aiming to achieve with the schema: For example,
type CarSchema = {
mark: Joi.string().required(),
color: Joi.string().required(),
price: Joi.number().required(),
accessories: Joi.string().optional(),
}