@NotBlank(message = "Missing ID_IMG_CHECK.")
以上标签进行验证时是无条件验证,如果想在特定条件下才验证,则不适用。
于是才有如下设定:
@NotBlank(message = "Missing ID_IMG_CHECK.", groups = {GroupA.class} )
手动验证:
Class<?> [] classArray = classList.toArray(new Class<?>[0]);
LOGGER.info("subVersion : {}, Validate class : {}", subVersion, classNameList);
CompositeException compositeException = new CompositeException();
Set<ConstraintViolation<QueryKycResultDetail>> groupSet = validator.validate(queryKycResultDetail, classArray);
https://www.baeldung.com/javax-validation-groups