A spec is a named, reusable validation rule for a single field or value — a shape a value must satisfy. You write the rule once, give it a typed error, and attach it wherever that shape is needed with specs [Name]. It is how a plain string becomes a SKU or a postal code without repeating the rule at every call site.
Declaring a spec
Chowk's SKU rule constrains a product code to uppercase letters, digits, and dashes:
spec Sku "A stock-keeping unit: 3–32 uppercase letters, digits, or dashes." {
expr "this.matches('^[A-Z0-9][A-Z0-9-]{2,31}