Working with Content Field Validations

Jesse Martin
Jesse Martin

July 22, 2020

Field validations allow you to control the accepted input of a field.

Validation types

RequiredA value must be present.
UniqueNo other entry may have an identical value defined for that field.
Character LimitText fields (single, multi and markdown) allow you to additionally limit the character input count between a given range.
Limit Input RangeIntegers and Floats allow you restrict the allowed numeric range for the fields (always inclusive) to an input between a given range.
PatternsText fields can be restricted by either disallowed text patterns or enforced text patterns. These are defined by standard Regular Expressions (RegExp) and do not need to be wrapped in opening or closing slashes.

You can modify these pattern searches with additional flags such as ignoring case, enabling multi-line search, single-line search or both.

Common patterns




^(?:(?:\(?(?:00|\+)([1-4]\d\d|[1-9]\d?)\)?)?[\-\.\ \\\/]?)?((?:\(?\d{1,}\)?[\-\.\ \\\/]?){0,})(?:[\-\.\ \\\/]?(?:#|ext\.?|extension|x)[\-\.\ \\\/]?(\d+))?$





Create a field validation

  1. Either add a new field to a model in the schema editor or click "edit field" on an existing field.
  2. Navigate to the second tab called "validations".
  3. Enable one of the following validations.mdx

Remove a field validation

  1. Navigate to the validation tab of your field settings.
  2. Change the validation you'd like to remove by unchecking the boolean next to the type of validation.

It's Easy To Get Started

GraphCMS plans are flexibly suited to accommodate your growth. Get started for free, or reach out to our sales team to discuss larger projects with more complex needs