Class ObjectValidation


  • public class ObjectValidation
    extends Object
    Validates the value of properties in a JavaBeans-like object. It scans for Validate* annotations at fields in the object, and for each annotation it performs the validation on the property value. The property value is obtained with PropertyReader. The value validation is done with Validation.
    • Constructor Detail

      • ObjectValidation

        public ObjectValidation()
    • Method Detail

      • validate

        public static Map<String,​List<String>> validate​(Object obj)
        Validates the property values in the specified object. It returns a map with errors. The keys are the property names with one or more errors. A value is a list of one or more error messages.
        Parameters:
        obj - the object to validate
        Returns:
        the validation result
      • getErrorMessage

        public static String getErrorMessage​(Map<String,​List<String>> validationResult)
        Generates an error message for the specified validation result. If there is no error, this method returns null. Otherwise it returns a string with each error on a separate line.
        Parameters:
        validationResult - the validation result
        Returns:
        the error message