You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I want to allow in thicknessRange property any of those values:
[1, 2] => OK
[1] => OK
[null, 2] => Not OK as null is not a number!
The problem:
I don't see any way to allow null in my array of numbers.
Usually, in order to allow null on a number, I add @IsOptional() decorator but in this case it make the entire array optional and it is not what I want.
I tried with @IsOptional({ each: true }) but it didn't work...
The text was updated successfully, but these errors were encountered:
I think resolving this issue with your current approach might be difficult.
This is because you are using IsNumber rules, which validate that each item in the array is a number.
I believe creating custom rules would be necessary to address your concerns.
How to validate an array of numbers where null is allowed?
I have the following command:
I want to allow in thicknessRange property any of those values:
The problem:
I don't see any way to allow null in my array of numbers.
Usually, in order to allow null on a number, I add @IsOptional() decorator but in this case it make the entire array optional and it is not what I want.
I tried with @IsOptional({ each: true }) but it didn't work...
The text was updated successfully, but these errors were encountered: