我有一个带有邮件验证功能的休息服务:
@Getter
@Setter
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class UserDTO {
private Integer userId;
@NotNull(groups = {CreateUserValidation.class, LoginUserValidation.class})
@NotEmpty(groups = {CreateUserValidation.class, LoginUserValidation.class})
@Email(groups = {CreateUserValidation.class, LoginUserValidation.class}, message = "Type email in proper format")
private String emailLogin;
现在,当有人给不正确的邮件时,我拥有所有日志:
"message": "Validation failed for argument [0] in public pl.betse.beontime.bo.UserDTO pl.betse.beontime.controller.UserController.createNewUser(pl.betse.beontime.bo.UserDTO): [Field error in object 'userDTO' on field 'emailLogin': rejected value [aa]; codes [Email.userDTO.emailLogin,Email.emailLogin,Email.java.lang.String,Email]; arguments [org.springframework.context.support.DefaultMessageSourceResolvable: codes [userDTO.emailLogin,emailLogin]; arguments []; default message [emailLogin],[Ljavax.validation.constraints.Pattern$Flag;@77b0d6c3,org.springframework.validation.beanvalidation.SpringValidatorAdapter$ResolvableAttribute@42164bc8]; default message [Type email in proper format]] "
我可以更改此信息以仅返回消息吗?有一些简单的方法可以做到这一点吗?