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
| Rule | Constraint type | Applies to | What it checks |
|---|---|---|---|
| Required | required | all 15 field types | Field has a non-empty value at submit time |
| Min length | minLength | text, textarea, email, phone | String is at least N characters |
| Max length | maxLength | text, textarea, email, phone | String is at most N characters |
| Pattern | pattern | text, textarea, email, phone | String matches a regular expression |
| Min | min | number, date, currency, date_range | Value ≥ N |
| Max | max | number, date, currency, date_range | Value ≤ N |
| Enum | enum | select, cascading_select, multi_select, radio_group, checkbox | Value 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 type | required |
| Constraint value | none (just the flag) |
| Applies to | every 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 type | minLength |
| Constraint value | integer (the minimum) |
| Applies to | text, textarea, email, phone |
# Example: a feedback textarea that requires at least a sentence
field: feedback
type: textarea
validation:
minLength: 20Maximum length
String value must be at most N characters. Common for titles, headlines, tweet-length fields.
| Constraint type | maxLength |
| Constraint value | integer (the maximum) |
| Applies to | text, textarea, email, phone |
# Example: an SMS-length status field
field: status
type: text
validation:
maxLength: 160Regex 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 type | pattern |
| Constraint value | regex source string (JavaScript regex syntax) |
| Applies to | text, 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 type | min |
| Constraint value | number (for number, currency), ISO-8601 date (for date, date_range) |
| Applies to | number, 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 type | max |
| Constraint value | number (for number, currency), ISO-8601 date (for date, date_range) |
| Applies to | number, 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 type | enum |
| Constraint value | array of allowed values |
| Applies to | select, 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.
Related
- Form field types — which rules each field type accepts
- Validate field types — recipe-form examples through the editor UI
- How forms work § Conditional-field model — how required interacts with hidden fields
- Your first form — tutorial that uses
requiredandenum