DocsFRL reference
On this page

Field rules reference

Look up validation, visibility and generated-field options.

Before you begin: Schema reference.

Schema Rules

RuleWorks withExample
requiredall field typesemail: { type: "string", required: true }
defaultliteral fields, moneybalance: { type: "money", default: 0 }
minstring, phone, number, money, arraybalance: { type: "money", min: 0 }
maxstring, phone, number, money, arraytags: { type: "array", max: 10 }
patternstring, phoneslug: { type: "string", pattern: "^[a-z0-9-]+$" }
enumsenumstatus: { type: "enum", enums: ["draft", "published"] }
minKeysobjectmeta: { type: "object", minKeys: 1 }
maxKeysobjectmeta: { type: "object", maxKeys: 20 }
maxDepthobjectmeta: { type: "object", maxDepth: 2 }
maxCharsobjectmeta: { type: "object", maxChars: 2000 }
uniquearraytags: { type: "array", unique: true }
uniqueByarray of objectsuniqueBy: "productId" or uniqueBy: ["productId", "variant.size"]
maxSizefileimage: { type: "file", maxSize: 3000000 }
mimeTypesfilefile: { type: "file", mimeTypes: ["application/pdf"] }
minVideoDuration, maxVideoDurationvideo fileDuration limits in seconds; minVideoDuration must be at least 1. Literals, FRL expressions, or helper functions.
maxVideoQualityvideo fileHighest prepared quality: 240, 360, 480, 720, or 1080.
videoDurationOverflowvideo file"reject" (default with maxVideoDuration), "trim" from the beginning, or "omit" for optional file fields.
maxDurationSecondsvideo fileOlder spelling that retains trim behavior. Prefer maxVideoDuration with videoDurationOverflow.
postTypepostcategory: { type: "post", postType: "categories" }
existspost, userexternalId: { type: "post", postType: "items", exists: false }
validateExistspost, userexternalId: { type: "post", postType: "items", validateExists: false }
visibilityall field typesprivateNote: { type: "string", visibility: "author" }
generatedall field typeslast4: { type: "string", generated: true }
immutableedit validationid: { type: "string", required: true, immutable: true }
editableIfedit validationstatus: { type: "string", editableIf: $admin.canEdit("products.status") }

Video-option expressions and functions can read verified source facts through $file.video.duration (seconds), width, height, and hasAudio, plus $file.size, $file.mimeType, and $file.fileName. $page provides site page settings. A duration rejection invalidates the entire post or user-profile write; a pending source check blocks saving until verification finishes.

visibility accepts public, author, or backend. public is the default. Author-visible fields are returned only to the post author, and backend-visible fields stay available to FRL rules and endpoint handlers without being returned to theme page data. Admin status does not bypass this in normal theme page responses.

generated: true marks a field as server-managed. Direct form and API values for that field are ignored before before hooks run. On edit, the saved value is preserved unless trusted FRL logic replaces it. Hooks, endpoints, payment events, and related post.* writes can supply generated values. The result still has to satisfy every declared field rule. generated does not change read access; combine it with visibility when necessary.

Continue with Context and operators reference.