Validators that check a form field value before submit, including {{ validators }}, the shared {{ validator }} shape, and each typed validator object.
Some field types expose a {{ validators }} object; others do not. That object is not polymorphic: object_type is always validators, and validators holds a flat list of validator objects.
Each item in that list is polymorphic. Liquid exposes the shared shape as {{ validator }}, but at runtime each item is one of the typed validator objects on this page. Use object_type or type to tell which implementing type you have.
Unlike conditions, multiple validators are not grouped with and/or. They sit in one flat list. {{ validator }} documents only the shared properties (object_type, is_valid, type, and message). Typed objects add the rest.
These are form-field validators, not Liquid {% if %} operators.
{{ validators }}
The validators object on a form field. This object is not polymorphic: object_type is always validators. Some field types expose it; others do not. validators holds a flat list of validator objects, and each of those is one of the typed validator objects.
ExampleShow a hint only when a field has validatorsNot every field type exposes {{ validators }}. Guard on is_valid before reading its list, since a field with none still returns the object.
Liquid
{%- if form_field.validators.is_valid -%}
<p class="field-hint">{{ form_field.validators.validators | size }} rule(s) apply to this field.</p>
{%- endif -%}
ExampleFall back to a generic message when a validator has none{{ validator }} always has message, but it is often blank so the runtime default applies. Build your own fallback with the type when you render messages yourself.
Liquid
{%- for v in form_field.validators.validators -%}
<li data-rule="{{ v.type }}">{{ v.message | default: v.type | append: " validation failed" }}</li>
{%- endfor -%}
{{ validator }}
{{ validator }} is the shared shape for one form-field validator. It is not a separate runtime type: each item in the validators list is one of the typed validator objects on this page (email_validator, maxsize_validator, and the rest). Use object_type or type to tell which implementing type you have.
Typed validator objects add further properties that are not listed here (for example value or field_id). See each type on this page.
ExampleFall back to a generic message when a validator has none{{ validator }} always has message, but it is often blank so the runtime default applies. Build your own fallback with the type when you render messages yourself.
Liquid
{%- for v in form_field.validators.validators -%}
<li data-rule="{{ v.type }}">{{ v.message | default: v.type | append: " validation failed" }}</li>
{%- endfor -%}
{{ alphanumeric_validator }}
A form-field validator that requires the value to contain only letters and numbers.
Properties
Properties of {{ alphanumeric_validator }} objects
ExampleShow a required-format hint for a validatoralphanumeric_validator, decimal_validator, email_validator, number_validator, phone_validator, and url_validator all share the same shape — a format check with no extra properties beyond message.
Liquid
{%- for v in form_field.validators.validators -%}
<li>Must be a valid {{ v.type }}.</li>
{%- endfor -%}
{{ decimal_validator }}
A form-field validator that requires the value to be a decimal number.
ExampleShow a required-format hint for a validatoralphanumeric_validator, decimal_validator, email_validator, number_validator, phone_validator, and url_validator all share the same shape — a format check with no extra properties beyond message.
Liquid
{%- for v in form_field.validators.validators -%}
<li>Must be a valid {{ v.type }}.</li>
{%- endfor -%}
{{ different_validator }}
A form-field validator that requires the value to differ from another field.
ExampleCompare a validator against another fielddifferent_validator and same_validator both compare this field to another field by field_id, requiring the values to differ or match.
Liquid
{%- for v in form_field.validators.validators -%}
{%- if v.object_type == "different_validator" -%}
<li>Must differ from {{ v.field_id }}</li>
{%- elsif v.object_type == "same_validator" -%}
<li>Must match {{ v.field_id }}</li>
{%- endif -%}
{%- endfor -%}
{{ email_validator }}
A form-field validator that requires the value to be an email address.
ExampleShow a required-format hint for a validatoralphanumeric_validator, decimal_validator, email_validator, number_validator, phone_validator, and url_validator all share the same shape — a format check with no extra properties beyond message.
Liquid
{%- for v in form_field.validators.validators -%}
<li>Must be a valid {{ v.type }}.</li>
{%- endfor -%}
{{ eq_validator }}
A form-field validator that requires the value to equal a given value.
ExampleRequire a field to equal, or not equal, a fixed valueeq_validator and not_validator both compare against a literal value, never another field — they are opposite tests of the same shape.
Liquid
{%- for v in form_field.validators.validators -%}
{%- if v.object_type == "eq_validator" -%}
<li>Must equal "{{ v.value }}"</li>
{%- elsif v.object_type == "not_validator" -%}
<li>Must not equal "{{ v.value }}"</li>
{%- endif -%}
{%- endfor -%}
{{ gt_validator }}
A form-field validator that requires the value to be greater than a given value or another field.
ExampleRead a validator that compares to a value or another fieldgt_validator and gte_validator compare against either a literal value or another field — field_id is set only when comparing to a field, so value is the fallback.
Liquid
{%- for v in form_field.validators.validators -%}
{%- if v.object_type == "gt_validator" -%}
<li>Must be greater than {{ v.field_id | default: v.value }}</li>
{%- elsif v.object_type == "gte_validator" -%}
<li>Must be {{ v.field_id | default: v.value }} or greater</li>
{%- endif -%}
{%- endfor -%}
{{ gte_validator }}
A form-field validator that requires the value to be greater than or equal to a given value or another field.
ExampleRead a validator that compares to a value or another fieldgt_validator and gte_validator compare against either a literal value or another field — field_id is set only when comparing to a field, so value is the fallback.
Liquid
{%- for v in form_field.validators.validators -%}
{%- if v.object_type == "gt_validator" -%}
<li>Must be greater than {{ v.field_id | default: v.value }}</li>
{%- elsif v.object_type == "gte_validator" -%}
<li>Must be {{ v.field_id | default: v.value }} or greater</li>
{%- endif -%}
{%- endfor -%}
{{ lt_validator }}
A form-field validator that requires the value to be less than a given value or another field.
ExampleRead a validator that compares to a value or another field, on the low sidelt_validator and lte_validator compare against either a literal value or another field — field_id is set only when comparing to a field, so value is the fallback.
Liquid
{%- for v in form_field.validators.validators -%}
{%- if v.object_type == "lt_validator" -%}
<li>Must be less than {{ v.field_id | default: v.value }}</li>
{%- elsif v.object_type == "lte_validator" -%}
<li>Must be {{ v.field_id | default: v.value }} or less</li>
{%- endif -%}
{%- endfor -%}
{{ lte_validator }}
A form-field validator that requires the value to be less than or equal to a given value or another field.
ExampleRead a validator that compares to a value or another field, on the low sidelt_validator and lte_validator compare against either a literal value or another field — field_id is set only when comparing to a field, so value is the fallback.
Liquid
{%- for v in form_field.validators.validators -%}
{%- if v.object_type == "lt_validator" -%}
<li>Must be less than {{ v.field_id | default: v.value }}</li>
{%- elsif v.object_type == "lte_validator" -%}
<li>Must be {{ v.field_id | default: v.value }} or less</li>
{%- endif -%}
{%- endfor -%}
{{ maxitems_validator }}
A form-field validator that requires a list field to have at most a given number of selected items.
ExampleEnforce a selection-count validator's limitmaxitems_validator and minitems_validator both count selections on a list field; value holds the limit, same shape as their condition counterparts.
Liquid
{%- for v in form_field.validators.validators -%}
{%- if v.object_type == "maxitems_validator" -%}
<li>Choose {{ v.value }} or fewer</li>
{%- elsif v.object_type == "minitems_validator" -%}
<li>Choose at least {{ v.value }}</li>
{%- endif -%}
{%- endfor -%}
{{ maxlength_validator }}
A form-field validator that requires the value to be no longer than a given number of characters.
ExampleEnforce a character-count validator's limitmaxlength_validator and minlength_validator both count characters in a text value; value holds the limit.
Liquid
{%- for v in form_field.validators.validators -%}
{%- if v.object_type == "maxlength_validator" -%}
<li>{{ v.value }} characters or fewer</li>
{%- elsif v.object_type == "minlength_validator" -%}
<li>At least {{ v.value }} characters</li>
{%- endif -%}
{%- endfor -%}
{{ maxsize_validator }}
A form-field validator that limits the size of an uploaded file.
ExampleShow the upload size limit from a maxsize_validatormaxsize_validator is the only typed validator that limits an uploaded file rather than a text, number, or list value.
Liquid
{%- for v in form_field.validators.validators -%}
{%- if v.object_type == "maxsize_validator" -%}
<li>File must be under {{ v.value }}</li>
{%- endif -%}
{%- endfor -%}
{{ minitems_validator }}
A form-field validator that requires a list field to have at least a given number of selected items.
ExampleEnforce a selection-count validator's limitmaxitems_validator and minitems_validator both count selections on a list field; value holds the limit, same shape as their condition counterparts.
Liquid
{%- for v in form_field.validators.validators -%}
{%- if v.object_type == "maxitems_validator" -%}
<li>Choose {{ v.value }} or fewer</li>
{%- elsif v.object_type == "minitems_validator" -%}
<li>Choose at least {{ v.value }}</li>
{%- endif -%}
{%- endfor -%}
{{ minlength_validator }}
A form-field validator that requires the value to be at least a given number of characters.
ExampleEnforce a character-count validator's limitmaxlength_validator and minlength_validator both count characters in a text value; value holds the limit.
Liquid
{%- for v in form_field.validators.validators -%}
{%- if v.object_type == "maxlength_validator" -%}
<li>{{ v.value }} characters or fewer</li>
{%- elsif v.object_type == "minlength_validator" -%}
<li>At least {{ v.value }} characters</li>
{%- endif -%}
{%- endfor -%}
{{ not_validator }}
A form-field validator that requires the value not to equal a given value.
ExampleRequire a field to equal, or not equal, a fixed valueeq_validator and not_validator both compare against a literal value, never another field — they are opposite tests of the same shape.
Liquid
{%- for v in form_field.validators.validators -%}
{%- if v.object_type == "eq_validator" -%}
<li>Must equal "{{ v.value }}"</li>
{%- elsif v.object_type == "not_validator" -%}
<li>Must not equal "{{ v.value }}"</li>
{%- endif -%}
{%- endfor -%}
{{ number_validator }}
A form-field validator that requires the value to be an integer number.
ExampleShow a required-format hint for a validatoralphanumeric_validator, decimal_validator, email_validator, number_validator, phone_validator, and url_validator all share the same shape — a format check with no extra properties beyond message.
Liquid
{%- for v in form_field.validators.validators -%}
<li>Must be a valid {{ v.type }}.</li>
{%- endfor -%}
{{ phone_validator }}
A form-field validator that requires the value to be a phone number.
ExampleShow a required-format hint for a validatoralphanumeric_validator, decimal_validator, email_validator, number_validator, phone_validator, and url_validator all share the same shape — a format check with no extra properties beyond message.
Liquid
{%- for v in form_field.validators.validators -%}
<li>Must be a valid {{ v.type }}.</li>
{%- endfor -%}
{{ regex_validator }}
A form-field validator that requires the value to match a regular expression.
ExampleShow the pattern a regex_validator requiresregex_validator tests the field value against value, a regular expression, and can invert the test to require a non-match instead.
Liquid
{%- for v in form_field.validators.validators -%}
{%- if v.object_type == "regex_validator" -%}
<li>Must match pattern {{ v.value }}</li>
{%- endif -%}
{%- endfor -%}
{{ same_validator }}
A form-field validator that requires the value to match another field.
ExampleCompare a validator against another fielddifferent_validator and same_validator both compare this field to another field by field_id, requiring the values to differ or match.
Liquid
{%- for v in form_field.validators.validators -%}
{%- if v.object_type == "different_validator" -%}
<li>Must differ from {{ v.field_id }}</li>
{%- elsif v.object_type == "same_validator" -%}
<li>Must match {{ v.field_id }}</li>
{%- endif -%}
{%- endfor -%}
{{ url_validator }}
A form-field validator that requires the value to be a URL.
ExampleShow a required-format hint for a validatoralphanumeric_validator, decimal_validator, email_validator, number_validator, phone_validator, and url_validator all share the same shape — a format check with no extra properties beyond message.
Liquid
{%- for v in form_field.validators.validators -%}
<li>Must be a valid {{ v.type }}.</li>
{%- endfor -%}