Server-Side Validation

Last updated on June 26, 2024.

Data integrity is critical to any business or project. There are various ways to design systems with robust data integrity, and one of the most basic ways is to implement data validation. In Insites, server-side validation can be done in 2 ways: Forms and GraphQL.

Forms

Insites form validations are only triggered after submission. When a field/data does not meet the 'requirements' set on the server, it will stop the process and return the error via the context.flash liquid tag.

More information about Insites form validation and error handling:

GraphQL

Form validation also works when we use it on a graphQL mutation. Simply add form_name on your mutation, referring to the form it will reference. If there are validation errors encountered on the graphQL, it will return the form’s error as part of the graphQL data response.

Sample model schema:

Sample model form configuration:

Sample graphQL mutation with form reference:

Important: Once you relate a form to a graphQL, regardless if your graphQL fields passed, it will only process fields / data defined on your form. If we reuse the previous form example for the graphQL below, it will not process the email field because ‘email’ field does not exist on the form configuration.

Have a suggestion for this page?

Didn't quite find what you are looking for or have feedback on how we can make the content better then we would love to hear from you. Please provide us feedback and we will get back to you shortly.