Constraints message in validator of play20

丶灬走出姿态 提交于 2019-12-19 08:52:02

问题


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


回答1:


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;


来源:https://stackoverflow.com/questions/9826817/constraints-message-in-validator-of-play20

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!