Package eu.woolplatform.utils.validation
Class ObjectValidation
- java.lang.Object
-
- eu.woolplatform.utils.validation.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 withPropertyReader. The value validation is done withValidation.
-
-
Constructor Summary
Constructors Constructor Description ObjectValidation()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static StringgetErrorMessage(Map<String,List<String>> validationResult)Generates an error message for the specified validation result.static Map<String,List<String>>validate(Object obj)Validates the property values in the specified object.
-
-
-
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
-
-