I am currently implementing Joi for validating JSON schemas, and I am in need of removing validation for a specific key (id) within a basic object in the main schema.
Here is an example of the schema I am working with:
const schema = Joi.object({
id: Joi.string().required(),
operation: Joi.string().required(),
// Other keys...
});
I have tried to create a new schema (newSchema) by utilizing the .keys() method to eliminate the validation for the id key, as shown here:
const newSchema = schema.concat(Joi.object({
id: Joi.any().optional(), // Attempted approach
}));
Unfortunately, this method does not seem to produce the desired outcome.
My goal is to generate a new schema identical to the original but without the validation for the id key:
Is there a way to eliminate the validation for the id key within a basic object using Joi?