ValidationMessage
Validation messages are returned when mutation input does not meet the requirements. While client-side validation is highly recommended to provide the best User Experience, All inputs will always be validated server-side.
Some examples of validations are:
Username must be at least 10 characters
Email field does not contain an email address
Birth Date is required
While GraphQL has support for required values, mutation data fields are always set to optional in our API. This allows 'required field' messages to be returned in the same manner as other validations. The only exceptions are id fields, which may be required to perform updates or deletes.
type ValidationMessage {
field: String
message: String
code: String!
template: String
options: [ValidationOption]
}
Fields
field
(String
)
The input field that the error applies to. The field can be used to identify which field the error message should be displayed next to in the presentation layer.
If there are multiple errors to display for a field, multiple validation messages will be in the result.
This field may be null in cases where an error cannot be applied to a specific field.
message
(String
)
A friendly error message, appropriate for display to the end user.
The message is interpolated to include the appropriate variables.
Example: Username must be at least 10 characters
This message may change without notice, so we do not recommend you match against the text. Instead, use the code field for matching.
code
(String!
)
A unique error code for the type of validation used.
template
(String
)
A template used to generate the error message, with placeholders for option substiution.
Example: Username must be at least {count} characters
This message may change without notice, so we do not recommend you match against the text. Instead, use the code field for matching.
options
([ValidationOption]
)
A list of substitutions to be applied to a validation message template