AndrewKeig / express-validation

express-validation is an express middleware that validates a request and returns a response with errors; if any of the configured validation rules fail.
MIT License
393 stars 85 forks source link

JoiError and ValidationError type clashing #136

Closed cmdcarini closed 2 years ago

cmdcarini commented 3 years ago

The fix introduced in https://github.com/AndrewKeig/express-validation/pull/134 actually made our TS build pass. In versions before (and after) v3.0.7, our usage of the constructor ValidationError(message, details/req, original/res) fails as it isn't expecting parameters in the constructor (because one isn't defined by express-validation, but is in Joi).

Ex. of TS code that works in v3.0.7 but not in other versions

const error = new ValidationError('test', { body: [] }, {});

Any suggestions? For now we'll just stay on v3.0.7

papandreou commented 2 years ago

The change from #134 was reverted in 71b746e8e614f3abe9aea71a6beeed3d2a56e5b9, which was released in 3.1.0.

papandreou commented 2 years ago

2nd attempt: https://github.com/AndrewKeig/express-validation/pull/157

The params for ValidationError are slightly different from what you put above: It's new ValidationError({ body: [] }, {});

papandreou commented 2 years ago

Should be fixed in 4.0.1 now.