Package com.oorian.validation
Class ValidationMessage
java.lang.Object
com.oorian.validation.ValidationMessage
A validation message with severity level.
ValidationMessage represents a single message produced during validation, such as an error, warning, or informational message. Each message has a severity level and optional field name for form-level error association.
Usage:
// Simple error message
ValidationMessage error = new ValidationMessage("Email is required", Severity.ERROR);
// Field-specific message
ValidationMessage fieldError = new ValidationMessage(
"Password must be at least 8 characters",
Severity.ERROR,
"password"
);
// Warning message
ValidationMessage warning = new ValidationMessage(
"This email domain is unusual",
Severity.WARNING
);
- Since:
- 2025
- Version:
- 1.0
- Author:
- Marvin P. Warble Jr.
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumSeverity levels for validation messages. -
Constructor Summary
ConstructorsConstructorDescriptionValidationMessage(String text, ValidationMessage.Severity severity) Creates a validation message with the specified text and severity.ValidationMessage(String text, ValidationMessage.Severity severity, String fieldName) Creates a validation message with the specified text, severity, and field name. -
Method Summary
Modifier and TypeMethodDescriptionReturns the field name this message relates to, if any.Returns the severity level of this message.getText()Returns the message text.booleanisError()Returns whether this message represents an error.booleanisInfo()Returns whether this message is informational.booleanReturns whether this message represents a warning.toString()
-
Constructor Details
-
ValidationMessage
Creates a validation message with the specified text and severity.- Parameters:
text- The message text to displayseverity- The severity level of the message
-
ValidationMessage
Creates a validation message with the specified text, severity, and field name.- Parameters:
text- The message text to displayseverity- The severity level of the messagefieldName- The name of the field this message relates to (for form-level messages)
-
-
Method Details
-
getText
Returns the message text.- Returns:
- The message text
-
getSeverity
Returns the severity level of this message.- Returns:
- The severity level
-
getFieldName
Returns the field name this message relates to, if any.- Returns:
- The field name, or null if this is not a field-specific message
-
isError
public boolean isError()Returns whether this message represents an error.- Returns:
- true if severity is ERROR
-
isWarning
public boolean isWarning()Returns whether this message represents a warning.- Returns:
- true if severity is WARNING
-
isInfo
public boolean isInfo()Returns whether this message is informational.- Returns:
- true if severity is INFO
-
toString
-