Record Class ValidationErrors
java.lang.Object
java.lang.Record
com.inductiveautomation.ignition.gateway.config.ValidationErrors
- Record Components:
messages
- Validation error messages that are not associated with a specific fieldfieldMessages
- Validation messages that are associated with a specific field. The key is the field name, and the value is a list of messages for that field.
public record ValidationErrors(List<String> messages, List<ValidationErrors.FieldValidationErrors> fieldMessages)
extends Record
This record (which is designed to be directly GSON-serializable) models validation error messages. There are
both general messages and field-specific messages.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
static final record
-
Constructor Summary
ConstructorsConstructorDescriptionValidationErrors
(List<String> messages, List<ValidationErrors.FieldValidationErrors> fieldMessages) Creates an instance of aValidationErrors
record class. -
Method Summary
Modifier and TypeMethodDescriptionfinal boolean
Indicates whether some other object is "equal to" this one.Returns the value of thefieldMessages
record component.static ValidationErrors
Creates a new ValidationErrors object with a single message for a single field.static ValidationErrors
forMessage
(String message) Creates a new ValidationErrors object with a single message that is not associated with a fieldfinal int
hashCode()
Returns a hash code value for this object.boolean
isEmpty()
messages()
Returns the value of themessages
record component.static ValidationErrors.Builder
final String
toString()
Returns a string representation of this record class.void
write
(jakarta.servlet.http.HttpServletResponse response) Writes the validation errors to the response as JSON with an HTTP 422 status code.
-
Constructor Details
-
ValidationErrors
public ValidationErrors(List<String> messages, List<ValidationErrors.FieldValidationErrors> fieldMessages) Creates an instance of aValidationErrors
record class.- Parameters:
messages
- the value for themessages
record componentfieldMessages
- the value for thefieldMessages
record component
-
-
Method Details
-
isEmpty
public boolean isEmpty()- Returns:
- true if there are no validation messages
-
write
public void write(jakarta.servlet.http.HttpServletResponse response) Writes the validation errors to the response as JSON with an HTTP 422 status code.- Throws:
IllegalStateException
- if there are no validation messages
-
forField
Creates a new ValidationErrors object with a single message for a single field. -
forMessage
Creates a new ValidationErrors object with a single message that is not associated with a field -
newBuilder
-
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
hashCode
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
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)
. -
messages
Returns the value of themessages
record component.- Returns:
- the value of the
messages
record component
-
fieldMessages
Returns the value of thefieldMessages
record component.- Returns:
- the value of the
fieldMessages
record component
-