whefter / nestjs-joi

Easy to use JoiPipe as an interface between joi and NestJS with optional decorator-based schema construction.
MIT License
25 stars 12 forks source link

Using JoiSchema for custom Error in Joi throws Cannot read property 'map' of undefined #4

Closed sreeteja06 closed 3 years ago

sreeteja06 commented 3 years ago

Usage

@JoiSchema(
    Joi.string()
      .required()
      .trim()
      .regex(passwordPattern)
      .error(
        new Error(
          `password must contain 1 number, 1 upper, 1 lower, 1 special and should be 8 chars long`,
        ),
      ),
  )
  password: string;

Error

TypeError: Cannot read property 'map' of undefined
    at Function.validate (P:\Projects\9and9\srisailam\srisailam-backend\node_modules\nestjs-joi\internal\joi.pipe.js:78:43)
    at JoiPipe.transform (P:\Projects\9and9\srisailam\srisailam-backend\node_modules\nestjs-joi\internal\joi.pipe.js:73:26)
whefter commented 3 years ago

Thanks for the submission, fixed in v1.3.1. Custom errors are now passed through.