Reputation: 528
I'm working on a NestJs app with graphql, and I'm trying to sanitize my resolvers inputs with class-transformer like this :
@InputType()
export class CreateUserInput {
@Field(() => String)
@Transform(({ value }) => value.trim())
email!: string;
}
But the Transform content is never executed.
How can I sanitize properly with decorator in an InputType ?
Upvotes: 1
Views: 1589
Reputation: 70171
To use the @Transform()
decorator, you need to have the ValidationPipe
bound to the route, resolver, or server, and you need to set the transform
option to true
Upvotes: 6