Class ValidationUtil
java.lang.Object
jp.ecuacion.lib.core.util.ValidationUtil
Provides validation-related utilities.
-
Method Summary
Modifier and TypeMethodDescriptionstatic <T> Set<jakarta.validation.ConstraintViolation<T>> validate(T object) Validates and returnsConstraintViolationif validation errors exist.static <T> Optional<MultipleAppException> validateThenReturn(T object) Validates and returnsMultipleAppExceptionif validation errors exist.static <T> Optional<MultipleAppException> validateThenReturn(T object, Boolean addsItemNameToMessage, PropertyFileUtil.Arg messagePrefix, PropertyFileUtil.Arg messagePostfix) Validates and returnsMultipleAppExceptionif validation errors exist.static <T> voidvalidateThenThrow(T object) Validates and throwsMultipleAppExceptionif validation errors exist.static <T> voidvalidateThenThrow(T object, Boolean addsItemNameToMessage, PropertyFileUtil.Arg messagePrefix, PropertyFileUtil.Arg messagePostfix) Validates and throwsMultipleAppExceptionif validation errors exist.
-
Method Details
-
validate
@Nonnull public static <T> Set<jakarta.validation.ConstraintViolation<T>> validate(@RequireNonnull T object) Validates and returnsConstraintViolationif validation errors exist.- Type Parameters:
T- any class- Parameters:
object- object to validate- Returns:
- a Set of ConstraintViolation, may be null when no validation errors exist.
- See Also:
-
validateThenThrow
Validates and throwsMultipleAppExceptionif validation errors exist.- Type Parameters:
T- any class- Parameters:
object- object to validate- Throws:
MultipleAppException- MultipleAppException
-
validateThenThrow
public static <T> void validateThenThrow(@RequireNonnull T object, @Nullable Boolean addsItemNameToMessage, @Nullable PropertyFileUtil.Arg messagePrefix, @Nullable PropertyFileUtil.Arg messagePostfix) throws MultipleAppException Validates and throwsMultipleAppExceptionif validation errors exist.- Type Parameters:
T- any class- Parameters:
object- object to validate- Throws:
MultipleAppException- MultipleAppException
-
validateThenReturn
@Nonnull public static <T> Optional<MultipleAppException> validateThenReturn(@RequireNonnull T object) Validates and returnsMultipleAppExceptionif validation errors exist.- Type Parameters:
T- any class- Parameters:
object- object to validate- Returns:
- MultipleAppException, may be null when no validation errors exist.
-
validateThenReturn
@Nonnull public static <T> Optional<MultipleAppException> validateThenReturn(@RequireNonnull T object, @Nullable Boolean addsItemNameToMessage, @Nullable PropertyFileUtil.Arg messagePrefix, @Nullable PropertyFileUtil.Arg messagePostfix) Validates and returnsMultipleAppExceptionif validation errors exist.3 parameters are added to arguments in addition to object, which are meant to show understandable error messages for non-display-value-validations (like validations to uploaded excel files) when the message displaying setting designates messages are to be shown at the bottom of each item.
Prefix and postfix are used to additional explanation for error messages, like "About the uploaded excel file, ".- Type Parameters:
T- any class- Parameters:
object- object to validateaddsItemNameToMessage- you'll get message with itemName whentrueis specified. It may benull, which is equal tofalse.messagePrefix- Used when you want to put an additional message before the original message. It may benull, which means no messages added.messagePostfix- Used when you want to put an additional message after the original message. It may benull, which means no messages added.- Returns:
- MultipleAppException, may be null when no validation errors exist.
-