Include name inside error class-validator nest

Viewed 19

I would like to know if it is possible and how can I return the field name along with the validation error message.

Example: "message": { name: "Name is required", username: "Username is required", }

instead of:

"message": [ "Name is required", "Username is required", ]

1 Answers

I'm not sure this is what you want.

const message : {name : string, username : string} = {name :'alex', username : 'halo'}

So if you type to '{name : string, username : string}' typescript will allow only object that have keys name and username.

Related