Class ValidationError

    • Constructor Detail

      • ValidationError

        public ValidationError()
        Constructs a new ValidationError.
      • ValidationError

        public ValidationError​(javax.validation.ConstraintViolation<?> constraintViolation)
        Constructs a new ValidationError.
        Parameters:
        constraintViolation - the constraint violation
      • ValidationError

        public ValidationError​(String property,
                               String message)
        Constructs a new ValidationError.
        Parameters:
        property - the path for the property that resulted in the validation error
        message - the error message for the validation error
    • 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 convert
        capitalizePropertyNames - 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