class-transformer icon indicating copy to clipboard operation
class-transformer copied to clipboard

Order of decorator execution

Open Caperious opened this issue 4 years ago • 3 comments

I was trying to create a validation for a property, which has to be an array of lowercase strings. To ensure that the strings are lowercased, we wrote a transformer function for transforming all strings to lower case.

The problem is, that the transformer runs before the @IsArray validation. Is it possible to somehow set the order of the execution of the decorators? Changing the order doesn't help.

  @IsArray()
  @Transform((prop) => prop?.map((el) => el.toString().toLowerCase()))
  arrayProp: string[]

Caperious avatar Apr 14 '21 11:04 Caperious

Any updates on this question?

bombillazo avatar May 05 '21 04:05 bombillazo

I have the same problem (https://github.com/typestack/class-transformer/issues/741)

Anyone can explain this question?

@NoNameProvided

er230059 avatar May 19 '21 17:05 er230059

I also have same confusion

ryanpram avatar May 23 '23 07:05 ryanpram