← All examples
76

Canonical Grid model

Record Field Validation

Validate a whole record and individual fields against the proposed input batch, including aliases and a shared limit.

Scale
Small
Source
record-field-validation.grid
Length
7 lines
Collection
Advanced language
Level
Intermediate
Runtime
Portable
record-field-validation.grid
Get Grid
TAGS "records", "validation"
# Whole-record and exact member contracts share the proposed input batch.
input Limit = 10
input Order = {amount: 2, city: "London"} VALIDATE <> BLANK MESSAGE "Keep the record"
Alias = Order
VALIDATE FIELD Alias.amount <= Limit MESSAGE "Amount exceeds limit"
VALIDATE FIELD Order.city <> "" MESSAGE "Enter a city"