MichalLytek / class-transformer-validator

A simple plugin for class-transformer and class-validator which combines them in a nice and programmer-friendly API.
MIT License
200 stars 19 forks source link

Give an option to combine class-validator's decorators with class-transformer's "excludeExtraneousValues" ? #45

Open pauloendoh opened 1 year ago

pauloendoh commented 1 year ago

Since this package uses both class-validator and class-transformer, and many users complain on applying @Expose() on all fields in order to remove extraneous values, wouldn't it be possible to give an option to levarage the validation decorators?

Something like "excludeUnvalidatedFields"?

Or, perhaps, we could have something like @IsStringExpose(), that wraps both @IsString() and @Expose() ? I created this Gist as reference: https://gist.github.com/pauloendoh/f7d3194bae2ff121e78ce45589bd4ab2

MichalLytek commented 1 year ago

I think not. This library is just a simple wrapper around those two, but adding additional decorators that changes behavior is out of scope I think.