I have a requirement where in a validation constraint message I need to include the String.length() i.e.:
@max(value = 50, message = "Max length 50, observed length " + String.length())
However I can't do this because it needs to be passed a constant expression. Is there any simple way to deal with this or is it just best to create a separate method checking lengths?
In the end we did it with an EL expression:
@max(value = 50, message = "Max length 50, observed length ${String.length()}")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With