Class ModelValidationResults

java.lang.Object
mg.emberframework.core.data.ModelValidationResults

public class ModelValidationResults extends Object
Represents the validation results for a model's fields.

This class aggregates validation outcomes for individual fields, storing them in a map where each key is a field name and the value is a FieldValidationResult.

Since:
1.0.0
Version:
1.0.0
Author:
Sandratra NIAINA
  • Constructor Details

    • ModelValidationResults

      public ModelValidationResults()
      Default constructor.
    • ModelValidationResults

      public ModelValidationResults(Map<String,FieldValidationResult> exceptions)
      Constructs a validation result with a pre-populated map of field exceptions.
      Parameters:
      exceptions - the map of field names to their validation results
  • Method Details

    • containsException

      public boolean containsException()
      Checks if any field contains a validation exception.
      Returns:
      true if at least one field has an exception, false otherwise
    • getFieldExceptionMessage

      public String getFieldExceptionMessage(String field)
      Retrieves the exception message for a specific field.
      Parameters:
      field - the name of the field
      Returns:
      the exception message for the field, or an empty string if none exists
    • getFieldExceptionMessage

      public String getFieldExceptionMessage(String field, String separator)
      Retrieves the exception message for a specific field with a custom separator.
      Parameters:
      field - the name of the field
      separator - the separator to use between exception messages
      Returns:
      the concatenated exception messages for the field
    • getFieldExceptionValue

      public String getFieldExceptionValue(String field)
      Retrieves the value associated with a field's validation result.
      Parameters:
      field - the name of the field
      Returns:
      the value of the field from its validation result
    • addException

      public void addException(String field, Exception exception)
      Adds an exception to a field's validation result.
      Parameters:
      field - the name of the field
      exception - the exception to add
    • addFieldException

      public void addFieldException(String field, FieldValidationResult fieldExceptions)
      Adds a complete validation result for a field.
      Parameters:
      field - the name of the field
      fieldExceptions - the validation result to associate with the field
    • getFieldExceptions

      public FieldValidationResult getFieldExceptions(String field)
      Retrieves or creates the validation result for a specific field.
      Parameters:
      field - the name of the field
      Returns:
      the existing or new FieldValidationResult for the field
    • getFieldExceptions

      public Map<String,FieldValidationResult> getFieldExceptions()
      Gets the map of field validation results.
      Returns:
      the field exceptions map
    • setFieldExceptions

      public void setFieldExceptions(Map<String,FieldValidationResult> fieldExceptions)
      Sets the map of field validation results.
      Parameters:
      fieldExceptions - the map to set