Skip to Content
DocumentationReferenceFormsForm validation rules

Validation rules decide what counts as a valid value for a field. Attach them at author time; MakeBox runs them client-side as the submitter fills in and again at submit time before the submission is saved. A failing rule blocks submission and surfaces an error message inline.

Each field type whitelists the rules that apply to it. See Form field types for which rules each type accepts; see Validate field types for recipe-form examples of attaching rules through the editor UI.

Rule catalog

RuleConstraint typeApplies toWhat it checks
Requiredrequiredall 15 field typesField has a non-empty value at submit time
Min lengthminLengthtext, textarea, email, phoneString is at least N characters
Max lengthmaxLengthtext, textarea, email, phoneString is at most N characters
Patternpatterntext, textarea, email, phoneString matches a regular expression
Minminnumber, date, currency, date_rangeValue ≥ N
Maxmaxnumber, date, currency, date_rangeValue ≤ N
Enumenumselect, cascading_select, multi_select, radio_group, checkboxValue is one of an explicit set

Required

Field must have a non-empty value when the submitter clicks Submit. The most universal rule — every field type accepts it.

Constraint typerequired
Constraint valuenone (just the flag)
Applies toevery field type

An empty string, null, undefined, an empty array, or an empty object all fail required. For a Checkbox, required means the box must be checked (value true); unchecked (false) is treated as empty.

Interaction with conditional display: if a field is hidden by a conditional-field rule, its required setting doesn’t fire. Hidden + required = valid. See How forms work § Conditional-field model for the full semantics.

String length

Length rules apply to the character count of the raw string value, before any trimming or formatting the UI control adds.

Minimum length

String value must be at least N characters.

Constraint typeminLength
Constraint valueinteger (the minimum)
Applies totext, textarea, email, phone
# Example: a feedback textarea that requires at least a sentence field: feedback type: textarea validation: minLength: 20

Maximum length

String value must be at most N characters. Common for titles, headlines, tweet-length fields.

Constraint typemaxLength
Constraint valueinteger (the maximum)
Applies totext, textarea, email, phone
# Example: an SMS-length status field field: status type: text validation: maxLength: 160

Regex pattern

String value must match a regular expression. Use for custom formats the built-in field types don’t enforce (postal codes, SKUs, employee IDs).

Constraint typepattern
Constraint valueregex source string (JavaScript regex syntax)
Applies totext, textarea, email, phone
# Example: U.S. ZIP code (5 digits or ZIP+4) field: zip type: text validation: pattern: "^\\d{5}(-\\d{4})?$"

Patterns are matched against the full value (anchor with ^ and $ to require a full match). Escape backslashes once per the pattern string’s embedding (YAML, JSON, or whatever carries it).

Numeric and date range

Range rules apply to numeric values and dates. The comparison is ≥ for min and ≤ for max — both inclusive.

Minimum value

Numeric or date value must be greater than or equal to the lower bound.

Constraint typemin
Constraint valuenumber (for number, currency), ISO-8601 date (for date, date_range)
Applies tonumber, currency, date, date_range
# Example: age must be 18 or older field: age type: number validation: min: 18 # Example: event date must be on or after today field: event_date type: date validation: min: "2025-01-01"

Maximum value

Numeric or date value must be less than or equal to the upper bound.

Constraint typemax
Constraint valuenumber (for number, currency), ISO-8601 date (for date, date_range)
Applies tonumber, currency, date, date_range
# Example: donation amount capped at $10,000 field: donation type: currency validation: max: 10000 # Example: birth date must be in the past field: birth_date type: date validation: max: "2025-12-31"

Choice

Enumerated allowed values

Value must be one of an explicit set. The set is usually the field’s option list — the enum rule exists to catch payloads submitted via API or pre-fill that bypass the UI’s option picker.

Constraint typeenum
Constraint valuearray of allowed values
Applies toselect, cascading_select, multi_select, radio_group, checkbox
# Example: priority dropdown with 3 allowed values field: priority type: select options: - value: low label: Low - value: med label: Medium - value: high label: High validation: enum: [low, med, high]

For Multi-select, every element of the submitted array must be in the allowed set. For Checkbox, the enum typically restricts to [true] (required-truthy) or [true, false] (default behavior).

Combining rules

A single field can carry multiple rules — they all evaluate independently, and a failure in any one blocks submission. The order rules are declared doesn’t affect evaluation (they all run), but the first failure is what the submitter sees in the error message.

# Example: a required email field with a length cap field: contact_email type: email validation: required: true maxLength: 254 pattern: "^[^@\\s]+@[^@\\s]+\\.[^@\\s]+$"

Only rules whitelisted for the field’s type can be attached. See Form field types for the per-type allow-list.

Last updated on