-
Notifications
You must be signed in to change notification settings - Fork 483
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: cannot read property 'name' of undefined #803
Comments
@inmativ can you try deleting the |
The error was due to the type "name: string" in the properties of the discriminator. This is what the working code looks like:
|
I'm facing same issue, adding // @ts-ignore doesn't help, even tried using strings in name field, still facing the issue, I think it is not related to Enum Error
Code:
|
For what it's worth, I had the same as you but this was caused by including |
This is my first issue. Please be friendly. Pardon my bad english.
Description
I am writing a project in NestJS. An error occurs when validating an array with objects of different types.
The error is reproduced only if you refer to the route using Postman. If you just call validate (new Facts (...)), everything works as expected. I tried on versions 0.3.1 and 0.4.0.
Discriminator parameters
Parent class decorators
FlightExecutionFactDTO and FlightFinishFactDTO extend FactDTO
Validation parameters
The error occurs when accessing the 'name' field, when the iteration does not find any matching element. The debugger shows that subType.value is one of the classes that extends FactDTO, and subValue.constructor is FactDTO itself. Of course, no coincidence occurs.
Expected behavior
The array of incoming objects is validated in accordance with the decorators of each object.
Actual behavior
An error is thrown when trying to match classes, as a result, the 'name' field cannot be read.
The text was updated successfully, but these errors were encountered: