Class Jsr380Validator
java.lang.Object
io.fluxzero.sdk.tracking.handling.validation.Jsr380Validator
- All Implemented Interfaces:
Validator
This validator uses JSR 380 annotations. However, before attempting method and type validations it will first attempt
field validations. This strategy prevents issues if one of the validated methods depends on one or more validated
fields but those fields are invalid.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncheckParameterValidity(Object target, Executable executable, Object[] arguments) Validates invocation arguments for a method or constructor and returns an optionalValidationExceptionwhen constraints are violated.checkValidity(T object, Class<?>... groups) Validates the given object and returns an optionalValidationExceptionif the object is invalid.static Jsr380Validatorprotected static Stringformat(jakarta.validation.ConstraintViolation<?> v, boolean fullPath) format(Collection<? extends jakarta.validation.ConstraintViolation<?>> violations, boolean fullPath) protected static StringgetPropertyPath(jakarta.validation.ConstraintViolation<?> v, boolean full) protected ValidationExceptionnewValidationException(Collection<? extends jakarta.validation.ConstraintViolation<?>> violations) Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface Validator
areParametersValid, assertValid, assertValidParameters, isValid
-
Constructor Details
-
Jsr380Validator
public Jsr380Validator()
-
-
Method Details
-
createDefault
-
checkValidity
Description copied from interface:ValidatorValidates the given object and returns an optionalValidationExceptionif the object is invalid.- Specified by:
checkValidityin interfaceValidator- Type Parameters:
T- the type of object being validated- Parameters:
object- the object to validategroups- optional validation groups to apply- Returns:
- an
Optionalcontaining the validation error if validation failed, or empty if valid
-
checkParameterValidity
public Optional<ValidationException> checkParameterValidity(@Nullable Object target, Executable executable, Object[] arguments) Description copied from interface:ValidatorValidates invocation arguments for a method or constructor and returns an optionalValidationExceptionwhen constraints are violated.- Specified by:
checkParameterValidityin interfaceValidator- Parameters:
target- the method target instance (ignored for constructors)executable- the executable being invokedarguments- invocation arguments- Returns:
- an optional validation exception
-
newValidationException
protected ValidationException newValidationException(Collection<? extends jakarta.validation.ConstraintViolation<?>> violations) -
format
protected SortedSet<String> format(Collection<? extends jakarta.validation.ConstraintViolation<?>> violations, boolean fullPath) -
format
-
getPropertyPath
-