Package rife.validation
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
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:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classstatic classstatic classstatic classstatic classstatic classstatic classstatic classstatic class -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionValidationError(String identifier, String subject) Creates a newValidationErrorinstance for the specified identifier and subject.ValidationError(String identifier, String subject, boolean overridable) Creates a newValidationErrorinstance for the specified identifier and subject. -
Method Summary
Modifier and TypeMethodDescriptionclone()booleanerroneousValue(Object erroneousValue) Chainable setter to make validation error construction easierReturns the erroneous value that caused the validation error, if it's present.final StringReturns the textual identifier that categorizes this validation error.final StringReturns the erroneous subject name of this validation error.inthashCode()final booleanReturns whether this error is overridable for the same subject.voidsetErroneousValue(Object erroneousValue) Stores the erroneous value that caused the validation error.
-
Field Details
-
IDENTIFIER_MANDATORY
- See Also:
-
IDENTIFIER_UNIQUENESS
- See Also:
-
IDENTIFIER_WRONG_LENGTH
- See Also:
-
IDENTIFIER_WRONG_FORMAT
- See Also:
-
IDENTIFIER_NOT_NUMERIC
- See Also:
-
IDENTIFIER_UNEXPECTED
- See Also:
-
IDENTIFIER_INCOMPLETE
- See Also:
-
IDENTIFIER_INVALID
- See Also:
-
IDENTIFIER_DIFFERENT
- See Also:
-
-
Constructor Details
-
ValidationError
Creates a newValidationErrorinstance for the specified identifier and subject.The error will not be automatic overridable.
- Parameters:
identifier- a non-nullStringwith the textual error identifiersubject- a non-nullStringwith the name of the erroneous subject- Since:
- 1.0
-
ValidationError
Creates a newValidationErrorinstance for the specified identifier and subject.- Parameters:
identifier- a non-nullStringwith the textual error identifiersubject- a non-nullStringwith the name of the erroneous subjectoverridable-trueto make any other error for the same subject override this error,falseif this error should always be shown- Since:
- 1.0
-
-
Method Details
-
getIdentifier
Returns the textual identifier that categorizes this validation error.- Since:
- 1.0
-
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
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
Chainable setter to make validation error construction easier- Since:
- 1.0
- See Also:
-
getErroneousValue
Returns the erroneous value that caused the validation error, if it's present.- Since:
- 1.0
-
clone
-
hashCode
public int hashCode() -
equals
-