com.lx.boot.web.valid.CheckValidator Maven / Gradle / Ivy
package com.lx.boot.web.valid;
import jakarta.validation.ConstraintValidator;
import jakarta.validation.ConstraintValidatorContext;
import lombok.extern.slf4j.Slf4j;
@Slf4j
public class CheckValidator implements ConstraintValidator {
private Check check;
@Override
public void initialize(Check check) {
this.check = check;
}
@Override
public boolean isValid(Object para, ConstraintValidatorContext constraintValidatorContext) {
try {
return check.function().newInstance().apply(new Validate(check.value(), check.ext(),para, constraintValidatorContext));
} catch (Exception e) {
log.error("验证参数出现异常,请检查是否实现Function的apply方法,或执行该方法是否抛异常.", e);
return false;
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy