On this page
Validate text and numbers
Constrain strings, enum values and numbers.
Before you begin: Choose field access and references.
String Rules
Rule excerpt: add this to a complete FRL rule before running it. Try a complete example →
| Rule | Meaning |
|---|---|
required | Value must not be undefined or null. |
min | Minimum string length. |
max | Maximum string length. |
pattern | A regular expression string, or a segmented pattern object for structured values. |
Use a regex string when a value belongs in one input. Use { segments, separator } when the value has meaningful parts, such as a card expiry, serial number, or grouped identifier. Each segment requires its own pattern and can include a user-facing name and placeholder. Frontbacked validates every segment and the literal separator, and admin forms can present the parts as dedicated inputs without guessing what a regex means.
Segment patterns validate one complete segment. The separator stays outside the segment patterns and is stored as part of the final string, so the example above stores 12/30.
Use type: "phone" for phone numbers. Frontbacked accepts common formatting such as spaces, dashes, and parentheses, normalizes the value, and requires a valid international number with a country code.
Enum Fields
Use type: "enum" when a field must be one of a few named options.
Rule excerpt: add this to a complete FRL rule before running it. Try a complete example →
Enum values are saved as strings, so FQL reads them normally:
Inside FRL, $this.fields exposes the enum values without repeating string literals:
Rule excerpt: add this to a complete FRL rule before running it. Try a complete example →
Use hasEnum(value) when a rule needs to check whether a value belongs to that field's enum list:
Rule excerpt: add this to a complete FRL rule before running it. Try a complete example →
Enum rules:
| Rule | Meaning |
|---|---|
required | Value must be present. |
enums | Allowed string values. |
default | Value to use on create when the field is missing or null. |
Number Rules
Rule excerpt: add this to a complete FRL rule before running it. Try a complete example →
| Rule | Meaning |
|---|---|
required | Value must be present. |
min | Minimum numeric value. |
max | Maximum numeric value. |
Continue with Validate objects and arrays.