Java Bean Validation using @DecimalMin @DecimalMax but also allow empty string?

Viewed 29

I came across a strange case that given following model class:

@DecimalMin("-10")
@DecimalMax("10")
String position;

And the client has a request that sets position to be an empty string "" and expects the validation to pass. This is something I cannot negotiate, so is there any way to work around such case? Something like:

@DecimalMin("-10")
@DecimalMax("10")
@Empty
String position;
0 Answers
Related