Class ValidationError
- java.lang.Object
-
- africa.absa.inception.core.service.ValidationError
-
- All Implemented Interfaces:
Serializable,Cloneable
public class ValidationError extends Object implements Serializable, Cloneable
The ValidationError class represents a validation error.- Author:
- Marcus Portmann
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description ValidationError()Constructs a new ValidationError.ValidationError(String property, String message)Constructs a new ValidationError.ValidationError(javax.validation.ConstraintViolation<?> constraintViolation)Constructs a new ValidationError.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static StringcapitalizePropertyName(String str)Capitalize each word in the string.static voidcapitalizePropertyNames(List<ValidationError> validationErrors)Capitalize the property names for the validation errors.StringgetMessage()Returns the error message for the validation error.StringgetProperty()Returns the path for the property that resulted in the validation error.voidsetMessage(String message)Set the error message for the validation error.voidsetProperty(String property)Set the path for the property that resulted in the validation error.static <T> List<ValidationError>toValidationErrors(Set<javax.validation.ConstraintViolation<T>> constraintViolations)Helper method to convert a set of JSR 303 constraint violations to a set of validation errors.static <T> List<ValidationError>toValidationErrors(Set<javax.validation.ConstraintViolation<T>> constraintViolations, boolean capitalizePropertyNames)Helper method to convert a set of JSR 303 constraint violations to a set of validation errors.
-
-
-
Method Detail
-
capitalizePropertyName
public static String capitalizePropertyName(String str)
Capitalize each word in the string.- Parameters:
str- the string- Returns:
- the capitalized string
-
capitalizePropertyNames
public static void capitalizePropertyNames(List<ValidationError> validationErrors)
Capitalize the property names for the validation errors.- Parameters:
validationErrors- the validation errors
-
toValidationErrors
public static <T> List<ValidationError> toValidationErrors(Set<javax.validation.ConstraintViolation<T>> constraintViolations)
Helper method to convert a set of JSR 303 constraint violations to a set of validation errors.- Type Parameters:
T- the type the constraint violations are associated with- Parameters:
constraintViolations- the JSR 303 constraint violations to convert- Returns:
- the validation errors
-
toValidationErrors
public static <T> List<ValidationError> toValidationErrors(Set<javax.validation.ConstraintViolation<T>> constraintViolations, boolean capitalizePropertyNames)
Helper method to convert a set of JSR 303 constraint violations to a set of validation errors.- Type Parameters:
T- the type the constraint violations are associated with- Parameters:
constraintViolations- the JSR 303 constraint violations to convertcapitalizePropertyNames- should the property names be capitilized- Returns:
- the validation errors
-
getMessage
public String getMessage()
Returns the error message for the validation error.- Returns:
- the error message for the validation error
-
getProperty
public String getProperty()
Returns the path for the property that resulted in the validation error.- Returns:
- the path for the property that resulted in the validation error
-
setMessage
public void setMessage(String message)
Set the error message for the validation error.- Parameters:
message- the error message for the validation error
-
setProperty
public void setProperty(String property)
Set the path for the property that resulted in the validation error.- Parameters:
property- the path for the property that resulted in the validation error
-
-