Class ValidationUtil
java.lang.Object
org.dellroad.stuff.validation.ValidationUtil
Validation utility methods.
-
Method Summary
Modifier and TypeMethodDescriptionstatic StringDescribe the validation errors in a friendly format.static StringescapeForTemplate(String message) Escape any special characters in the given literal string, returning an equivalent JSR 303 message template.static <T> Set<jakarta.validation.ConstraintViolation<T>> Validate the given object.
-
Method Details
-
validate
public static <T> Set<jakarta.validation.ConstraintViolation<T>> validate(T obj, Class<?>... groups) Validate the given object.This method simply creates a
ValidationContextwith the given root and invokesValidationContext.validate().- Type Parameters:
T- root validation object type- Parameters:
obj- object to validategroups- group(s) targeted for validation (if empty, defaults toDefault)- Returns:
- zero or more violations
- Throws:
IllegalArgumentException- if either paramter is null
-
describe
Describe the validation errors in a friendly format.- Parameters:
violations- validation violations- Returns:
- description of the validation errors
- Throws:
IllegalArgumentException- ifviolationsis null
-
escapeForTemplate
Escape any special characters in the given literal string, returning an equivalent JSR 303 message template.- Parameters:
message- plain message string- Returns:
- JSR 303 message template
- Throws:
IllegalArgumentException- ifmessageis null
-