public class validateClassName implements ConstraintValidator<ValidateCustomInterfaceName, BeanRequest > {
@SneakyThrows
@Override
public boolean isValid(BeanRequest bean, ConstraintValidatorContext context) {
if ((!bean.property1() && StringUtils.isBlank(bean.property1()))) {
throw new BadRequestException(ContentConstants.INVALID_REMARK);
}
return true;
}
}
@Target({TYPE})
@Retention(RetentionPolicy.RUNTIME)
@Constraint(validatedBy = { validateClassName.class })
public @interface ValidateCustomInterfaceName{
String message() default "";
Class<?>[] groups() default {};
Class<? extends Payload>[] payload() default {};
}
使用上面的代码可以返回check exception并使用@skeelythrows吗?
暂无答案!
目前还没有任何答案,快来回答吧!