Closed NicolaiVdS closed 1 year ago
I'm not sure what prisma-joi-generator
has to do with this question since I don't see it used in your code and I am unfamiliar with the library 🤔 That being said, I don't think the arguments you are passing into celebrate
are correct. celebrate
accepts an object, not a Joi schema. What happens if you do:
router.post('/create', celebrate({body: UserCreateSchema}), controller.createUser);
@NicolaiVdS are you all set? If so, can you please close this issue?
node
version - v16.14.0celebrate
version - 15.0.1joi
version (vianpm ls --depth=0 | grep joi
) - 17.7.0My
joi
schema looks like this:Schema is generated with
prisma-joi-generator
Example
UserCreateSchema: ```javascript import Joi from 'joi'; import { UserCreateInputSchemaObject } from './objects'; export const UserCreateSchema = Joi.object() .keys({ data: Joi.object().keys(UserCreateInputSchemaObject) }) .required(); ``` UserCreateInputSchemaObject: ```javascript // @ts-nocheck import Joi from 'joi'; import { AddressCreateNestedManyWithoutUserInputSchemaObject } from './AddressCreateNestedManyWithoutUserInput.schema'; export const UserCreateInputSchemaObject = { email: Joi.string().required(), password: Joi.string().required(), first_name: Joi.alternatives().try(Joi.string()), last_name: Joi.alternatives().try(Joi.string()), phone: Joi.alternatives().try(Joi.string()), addresses: Joi.object().keys(AddressCreateNestedManyWithoutUserInputSchemaObject), created_at: Joi.date(), }; ```The issue I am having with
celebrate
is:when using a schema generated with
prisma-joi-generator
as followedrouter.post('/create', celebrate(UserCreateSchema), controller.createUser);
i'm getting following erroris there a way i can use the generated schemas or do i need to make my own ?