feature: Range decorator for numbers #2550
Labels
flag: needs discussion
Issues which needs discussion before implementation.
type: feature
Issues related to new features.
Description
There are two string length check decorators:
@MinLength
and@MaxLength
.Additionally, there is a string decorator
@Length(min, max)
which checks if string length is in range betweenmin
andmax
.As a developer, having
@Min
and@Max
decorators for numbers, which works similar to@MinLength
and@MaxLength
, I would expect the third,@Range(min, max)
decorator, to be delivered with class-validator.Proposed solution
Create a new @range decorator for numbers, which is a combination of Min and Max decorators.
Code implementation suggestion:
It would simplify code for typical use case like this:
The same conditions with new decorator would look like this:
The text was updated successfully, but these errors were encountered: