Record Class Validation
java.lang.Object
java.lang.Record
org.inspirenxe.strata.api.component.Validation
- Record Components:
severity- how serious it ismessage- what the user should read, such as "Enter a number from 1 to 64"; empty forVALID
Whether a control's value is acceptable, and why not, as a
Validatable control shows it. An error marks the value
as wrong, such as "abc" in a quantity field; a warning marks it as allowed but worth a look, such as a weak
password.
box.setValidator(field -> field.text().isBlank() ? Validation.error(Text.of("Enter a name")) : Validation.VALID);
save.bind(Component.ENABLED, check.map(Validation::isValid));
-
Nested Class Summary
Nested Classes -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionValidation(Validation.Severity severity, Text message) Checks the arguments. -
Method Summary
Modifier and TypeMethodDescriptionfinal booleanIndicates whether some other object is "equal to" this one.static ValidationReturns an error: the value is wrong.final inthashCode()Returns a hash code value for this object.booleanisValid()Returns whether the value may be used, which is anything but an error, so a form can enable its Save button while its fields only warn.message()Returns the value of themessagerecord component.severity()Returns the value of theseverityrecord component.final StringtoString()Returns a string representation of this record class.static ValidationReturns a warning: the value is allowed but worth a look.
-
Field Details
-
VALID
Nothing to report.
-
-
Constructor Details
-
Validation
Checks the arguments.
-
-
Method Details
-
error
Returns an error: the value is wrong.- Parameters:
message- why, as the user should read it- Returns:
- the validation
-
warning
Returns a warning: the value is allowed but worth a look.- Parameters:
message- why, as the user should read it- Returns:
- the validation
-
isValid
public boolean isValid()Returns whether the value may be used, which is anything but an error, so a form can enable its Save button while its fields only warn.- Returns:
- true unless the severity is
Validation.Severity.ERROR
-
toString
-
hashCode
-
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared withObjects::equals(Object,Object). -
severity
-
message
-