For OTP length I am using 6, which I am taking from a variable
static final int OTP_LENGTH = 6;
@Size(min = OTP_LENGTH, max = OTP_LENGTH, message = "OTP Length should be {OTP_LENGTH} !!")
private String otp;
For which I am getting error mesage, if size is not of OTP_LENGTH.
"fieldErrors": [
{
"field": "password",
"message": "Not a Base64 string !!"
},
{
"field": "otp",
"message": "OTP Length should be {OTP_LENGTH} !!"
}
]
I also tried
@Size(min = OTP_LENGTH, max = OTP_LENGTH, message = "OTP Length should be ${OTP_LENGTH} !!")
private String otp;
But, OTP_LENGTH 6 is not setting.
Expectation :- "OTP Length should be 6 !!"
And, is there any other validator which takes only 1 length.
@Size, @Length can take max, @Size(max = OTP_LENGTH), but again min will be 0. If I will not override message, it will show length should be between 0 & 6.
OTP Length should be '${OTP_LENGTH}'?