molinjun / koa2-validation

A koa2 middleware to validate the request with Joi
MIT License
56 stars 7 forks source link

Not work with last Joi version (16.*.*) #19

Open repsak opened 4 years ago

repsak commented 4 years ago

In the latest version of the Joi, the validation method is called in the schema context, instead of the usual library context

Examples Before: Joi.validate(value, schema, [options], [callback])

After: schema.validate(data)

I had to make a hack for myself

const result = schema[item].validate(toValidateObj, options); instead const result = this.Joi.validate(toValidateObj, schema[item], options);

PS I apologize for my English

repsak commented 4 years ago

I noticed that the version of @hapi/joi in the koa2-validation package is currently 15.1.1 In the repository on the github she is 16.1.7 Did the assembly break?

Ha2ryZhang commented 4 years ago

how to fix it?

milgner commented 4 years ago

Upstream joi (not @hapi/joi anymore) is at v17 already. The published version uses 15.1.1 and I could only get it to run after downgrading my dependency to 15.1.1, too.