TypeError: Cannot read property 'prototype' of undefined
See original GitHub issueError appears here: https://github.com/typestack/class-validator/blob/master/src/metadata/MetadataStorage.ts#L79
Everything is quiet ordinar. I have this class for validation:
export class RegisterMasterBody {
@IsEmail()
email: string;
@MinLength(6)
password: string;
name: string;
instagram?: string;
description?: string;
lat?: number;
long?: number;
}
And here how I check for errors:
@Post()
@Render("register")
public async register(@Res() res: Response, @Body() body: RegisterMasterBody) {
try {
console.log(body, typeof body, body.constructor);
const errors = await validate(body, { skipMissingProperties: true });
console.log(errors, "errors of validate");
} catch (error) {
console.error(error, "POST REGISTER");
}
}
in console.log typeof body - “object”, constructor undefined
But inside here Error appears here: https://github.com/typestack/class-validator/blob/master/src/metadata/MetadataStorage.ts#L79 metadata.target is RegisterMasterBody
I tried to gather as much info as I can, since this is another project full of everything to strip it down and create repo with isolated reproduction 😦
Class validator is the same version as in this repo.
edit: worth mention - there are more properties that do not belong to RegisterMasterBody coming in request. But I tried adding them to RegisterMastBody - did not help
Issue Analytics
- State:
- Created 6 years ago
- Comments:9 (5 by maintainers)

Top Related StackOverflow Question
Same error here.
This is my code:
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.