我想在validation.yml中翻译errormessages。
如果我有一个正常的“NotBlank”规则,它的作用如下:
- NotBlank: { message: not.blank.firstname }
但是,如果有一些进一步的规则如下:
- NotBlank: { message: not.blank.username }
- Length:
min: 7
max: 50
minMessage: "Your Username must be at least {{ limit }} characters length"
这有效,但我应该如何处理minMessage?也是因为我想给用户一些关于输入最小长度的提示。
答案 0 :(得分:1)
您可以这样做:
- NotBlank: { message: not.blank.username }
- Length:
min: 7
max: 50
minMessage: 'username.minLength'
maxMessage: 'username.maxLength'
您的 validators.LANG.yml :
username:
minLength: "Your Username must be at least 7 characters length"
maxLength: "Your Username must be at least 50 characters length"