Class ValidationError

java.lang.Object
rife.validation.ValidationError
All Implemented Interfaces:
Cloneable
Direct Known Subclasses:
ValidationError.DIFFERENT, ValidationError.INCOMPLETE, ValidationError.INVALID, ValidationError.MANDATORY, ValidationError.NOT_NUMERIC, ValidationError.UNEXPECTED, ValidationError.UNIQUENESS, ValidationError.WRONG_FORMAT, ValidationError.WRONG_LENGTH

public abstract class ValidationError extends Object implements Cloneable
Instances of this class detail subjects that were found invalid during validation.

Each ValidationError is tied to a specific subject and provides more information through an explicative textual identifier.

A collection of commonly used identifiers and implementations are provided as static member variables and static inner classes.

Since:
1.0
See Also:
  • Field Details

  • Constructor Details

    • ValidationError

      public ValidationError(String identifier, String subject)
      Creates a new ValidationError instance for the specified identifier and subject.

      The error will not be automatic overridable.

      Parameters:
      identifier - a non-null String with the textual error identifier
      subject - a non-null String with the name of the erroneous subject
      Since:
      1.0
    • ValidationError

      public ValidationError(String identifier, String subject, boolean overridable)
      Creates a new ValidationError instance for the specified identifier and subject.
      Parameters:
      identifier - a non-null String with the textual error identifier
      subject - a non-null String with the name of the erroneous subject
      overridable - true to make any other error for the same subject override this error, false if this error should always be shown
      Since:
      1.0
  • Method Details

    • getIdentifier

      public final String getIdentifier()
      Returns the textual identifier that categorizes this validation error.
      Since:
      1.0
    • getSubject

      public final String getSubject()
      Returns the erroneous subject name of this validation error.
      Since:
      1.0
    • isOverridable

      public final boolean isOverridable()
      Returns whether this error is overridable for the same subject.
      Since:
      1.0
    • setErroneousValue

      public void setErroneousValue(Object erroneousValue)
      Stores the erroneous value that caused the validation error. This is optional and should only be done when the erroneous value gives more information from the context in which the validation error occurred.
      Since:
      1.0
    • erroneousValue

      public ValidationError erroneousValue(Object erroneousValue)
      Chainable setter to make validation error construction easier
      Since:
      1.0
      See Also:
    • getErroneousValue

      public Object getErroneousValue()
      Returns the erroneous value that caused the validation error, if it's present.
      Since:
      1.0
    • clone

      public Object clone()
      Overrides:
      clone in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object object)
      Overrides:
      equals in class Object