Package org.cyclos.utils
Class ValidationResult
- java.lang.Object
-
- org.cyclos.utils.ValidationResult
-
- All Implemented Interfaces:
Serializable
public class ValidationResult extends Object implements Serializable
Contains the results of a validation process. There might have general errors or property-specific errors.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static StringCUSTOM_FIELD_ERRORSstatic StringCUSTOM_FIELDSstatic StringGENERAL_ERRORSstatic StringPROPERTIESstatic StringPROPERTY_ERRORS
-
Constructor Summary
Constructors Constructor Description ValidationResult()ValidationResult(String error)Constructs a ValidationResult with a single general errorValidationResult(String name, String error)Constructs a ValidationResult with a single property error
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddCustomFieldError(String field, String error)Adds a custom field errorvoidaddGeneralError(String error)Adds a general errorvoidaddPropertyError(String property, String error)Adds a property errorList<String>getAllErrors()Map<String,List<String>>getCustomFieldErrors()List<String>getCustomFieldErrors(String customField)List<String>getCustomFields()StringgetFirstError()Returns the first validation error message, if anyList<String>getGeneralErrors()List<String>getProperties()Map<String,List<String>>getPropertyErrors()List<String>getPropertyErrors(String property)booleanhasCustomFieldErrors()Checks if there are any custom field errorsbooleanhasErrors()Checks if there are any errors, either general or property-specificbooleanhasGeneralErrors()Checks if there are any general errorsbooleanhasPropertyErrors()Checks if there are any property errorsvoidmerge(ValidationResult other, String propertyNamePrefix)Merges the givenValidationResultwith this, optionally prefixing the other property error names with the given prefixvoidsetCustomFieldErrors(Map<String,List<String>> customFieldErrors)voidsetCustomFields(List<String> customFields)voidsetGeneralErrors(List<String> generalErrors)voidsetProperties(List<String> properties)voidsetPropertyErrors(Map<String,List<String>> propertyErrors)voidthrowIfHasErrors()Throws aValidationExceptionwith this result if there are any errors, or returns silently if no errors.StringtoHtmlString(String errorTitle)StringtoString()
-
-
-
Field Detail
-
GENERAL_ERRORS
public static final String GENERAL_ERRORS
- See Also:
- Constant Field Values
-
PROPERTIES
public static final String PROPERTIES
- See Also:
- Constant Field Values
-
PROPERTY_ERRORS
public static final String PROPERTY_ERRORS
- See Also:
- Constant Field Values
-
CUSTOM_FIELDS
public static final String CUSTOM_FIELDS
- See Also:
- Constant Field Values
-
CUSTOM_FIELD_ERRORS
public static final String CUSTOM_FIELD_ERRORS
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
ValidationResult
public ValidationResult()
-
ValidationResult
public ValidationResult(String error)
Constructs a ValidationResult with a single general error
-
-
Method Detail
-
addCustomFieldError
public void addCustomFieldError(String field, String error)
Adds a custom field error
-
addGeneralError
public void addGeneralError(String error)
Adds a general error
-
getFirstError
public String getFirstError()
Returns the first validation error message, if any
-
hasCustomFieldErrors
public boolean hasCustomFieldErrors()
Checks if there are any custom field errors
-
hasErrors
public boolean hasErrors()
Checks if there are any errors, either general or property-specific
-
hasGeneralErrors
public boolean hasGeneralErrors()
Checks if there are any general errors
-
hasPropertyErrors
public boolean hasPropertyErrors()
Checks if there are any property errors
-
merge
public void merge(ValidationResult other, String propertyNamePrefix)
Merges the givenValidationResultwith this, optionally prefixing the other property error names with the given prefix
-
throwIfHasErrors
public void throwIfHasErrors() throws ValidationExceptionThrows aValidationExceptionwith this result if there are any errors, or returns silently if no errors.- Throws:
ValidationException
-
-