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 field
fieldMessages - 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.
  • Constructor Details

  • 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

      public static ValidationErrors forField(String fieldName, String message)
      Creates a new ValidationErrors object with a single message for a single field.
    • forMessage

      public static ValidationErrors forMessage(String message)
      Creates a new ValidationErrors object with a single message that is not associated with a field
    • newBuilder

      public static ValidationErrors.Builder newBuilder()
    • toString

      public final String 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.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • 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.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      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 with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • messages

      public List<String> messages()
      Returns the value of the messages record component.
      Returns:
      the value of the messages record component
    • fieldMessages

      Returns the value of the fieldMessages record component.
      Returns:
      the value of the fieldMessages record component