mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-07-21 15:09:48 +08:00
修改包描述,增加错误字段返回值
This commit is contained in:
@@ -80,7 +80,7 @@ public class BeanValidationResult {
|
||||
}
|
||||
|
||||
/**
|
||||
* 错误消息,包括字段名(字段路径)和消息内容
|
||||
* 错误消息,包括字段名(字段路径)、消息内容和字段值
|
||||
*/
|
||||
public static class ErrorMessage {
|
||||
/**
|
||||
@@ -91,6 +91,10 @@ public class BeanValidationResult {
|
||||
* 错误信息
|
||||
*/
|
||||
private String message;
|
||||
/**
|
||||
* 错误值
|
||||
*/
|
||||
private Object value;
|
||||
|
||||
public String getPropertyName() {
|
||||
return propertyName;
|
||||
@@ -108,11 +112,20 @@ public class BeanValidationResult {
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
public Object getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public void setValue(Object value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ErrorMessage{" +
|
||||
"propertyName='" + propertyName + '\'' +
|
||||
", message='" + message + '\'' +
|
||||
", value=" + value +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
@@ -98,7 +98,8 @@ public class ValidationUtil {
|
||||
ErrorMessage errorMessage = new ErrorMessage();
|
||||
errorMessage.setPropertyName(constraintViolation.getPropertyPath().toString());
|
||||
errorMessage.setMessage(constraintViolation.getMessage());
|
||||
result.getErrorMessages().add(errorMessage);
|
||||
errorMessage.setValue(constraintViolation.getInvalidValue());
|
||||
result.addErrorMessage(errorMessage);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/**
|
||||
* 基于JSR-303标准的校验工具类,封装了javax.validation的API
|
||||
* 基于JSR-380标准的校验工具类,封装了javax.validation的API
|
||||
*
|
||||
* @author chengqiang
|
||||
*/
|
||||
package cn.hutool.extra.validation;
|
||||
package cn.hutool.extra.validation;
|
||||
|
Reference in New Issue
Block a user