Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Constraints message in validator of play20

I would like to have a different message for a Constraints validator but i am wandering how to do.... example

@Constraints.Required
@Constraints.Pattern("\\d{1,6}")
public String thisIsAnInt;

I would like something

@Constraints.Required
    @Constraints.Pattern(message="ThisismyspecificMessage",value=\\d{1,6}")
    public String thisIsAnInt;

For showing it properly using the bootstrap in a form.

It is possible? thanks a lot

like image 763
user1286485 Avatar asked Dec 28 '22 03:12

user1286485


1 Answers

As you wrote, you can use

@Constraints.Required(message = "This is field required")
@Constraints.Pattern(value = "\\d{1,6}", message = "This field must contain from 1 to 6 digits")
public String thisIsAnInt;
like image 162
HEX Avatar answered Apr 16 '23 12:04

HEX