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 classstatic final record -
Constructor Summary
ConstructorsConstructorDescriptionValidationErrors(List<String> messages, List<ValidationErrors.FieldValidationErrors> fieldMessages) Creates an instance of aValidationErrorsrecord class. -
Method Summary
Modifier and TypeMethodDescriptionfinal booleanIndicates whether some other object is "equal to" this one.Returns the value of thefieldMessagesrecord component.static ValidationErrorsCreates a new ValidationErrors object with a single message for a single field.static ValidationErrorsforMessage(String message) Creates a new ValidationErrors object with a single message that is not associated with a fieldfinal inthashCode()Returns a hash code value for this object.booleanisEmpty()messages()Returns the value of themessagesrecord component.static ValidationErrors.Builderfinal StringtoString()Returns a string representation of this record class.voidwrite(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 aValidationErrorsrecord class.- Parameters:
messages- the value for themessagesrecord componentfieldMessages- the value for thefieldMessagesrecord 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
-
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). -
messages
-
fieldMessages
Returns the value of thefieldMessagesrecord component.- Returns:
- the value of the
fieldMessagesrecord component
-