use of net.sf.oval.context.FieldContext in project littlefisher-system by littlefishercoder.
the class ValidationHandler method publishValidationMessage.
/**
* 查找最根本的校验问题
* @param violationList 校验
* @param location 校验字段位置
*/
default void publishValidationMessage(List<ConstraintViolation> violationList, String location) {
if (CollectionUtil.isNotEmpty(violationList)) {
for (ConstraintViolation constraintViolation : violationList) {
if (ArrayUtils.isNotEmpty(constraintViolation.getCauses())) {
OValContext oValContext = constraintViolation.getContext();
if (oValContext instanceof FieldContext) {
FieldContext fieldContext = (FieldContext) oValContext;
location += "." + fieldContext.getField().getName();
} else if (oValContext instanceof ClassContext) {
ClassContext classContext = (ClassContext) oValContext;
location += "." + classContext.getClazz().getSimpleName();
}
publishValidationMessage(Lists.newArrayList(constraintViolation.getCauses()), location);
} else {
ExceptionHandler.publish("CORE-000009", null, location, constraintViolation.getMessage());
}
}
}
}
use of net.sf.oval.context.FieldContext in project littlefisher-system by littlefishercoder.
the class ValidationHandler method publishValidationMessage.
/**
* 查找最根本的校验问题
* @param violationList 校验
* @param location 校验字段位置
*/
default void publishValidationMessage(List<ConstraintViolation> violationList, String location) {
if (CollectionUtil.isNotEmpty(violationList)) {
for (ConstraintViolation constraintViolation : violationList) {
if (ArrayUtils.isNotEmpty(constraintViolation.getCauses())) {
OValContext oValContext = constraintViolation.getContext();
if (oValContext instanceof FieldContext) {
FieldContext fieldContext = (FieldContext) oValContext;
location += "." + fieldContext.getField().getName();
} else if (oValContext instanceof ClassContext) {
ClassContext classContext = (ClassContext) oValContext;
location += "." + classContext.getClazz().getSimpleName();
}
publishValidationMessage(Lists.newArrayList(constraintViolation.getCauses()), location);
} else {
ExceptionHandler.publish("CORE-000009", null, location, constraintViolation.getMessage());
}
}
}
}
Aggregations