All documentation

Validation

Phone normalization and the field rules applied to every write path.

One rule set, every path

The same validator runs on the API, the dashboard forms, CSV and XLSX import, and the Google Sheets sync. Anything valid in one path is valid in all of them, and client-side checks cannot be bypassed by calling the API directly.

Phone numbers

Numbers must be Moroccan and are canonicalized to +212XXXXXXXXX before storage, so the same customer is never dialed twice under two spellings. The subscriber part is 9 digits starting with 5 (landline), 6, or 7 (mobile). Spaces, dashes, dots, and parentheses are stripped, and the 0, 212, +212, and 00212 prefixes are all accepted. Anything else fails validation rather than being stored as-is.

Normalization examples

InputStored
0600112233+212600112233
+212 600-11-22-33+212600112233
00212600112233+212600112233
600112233+212600112233
0400112233rejected
+33612345678rejected

Field rules

FieldRequiredMax length
clientNameyes120
phoneyesvalid Moroccan number
storeNameyes120
productsNameyes500
addressno250

Validation error shape

400 Bad Request
{
  "error": "Invalid order fields",
  "code": "VALIDATION_ERROR",
  "fields": {
    "phone": "orders.form.errors.phoneInvalid",
    "clientName": "orders.form.errors.required"
  }
}

fields values are i18n keys, not display strings. Branch on the key; render your own copy.

Field error keys

KeyMeaning
orders.form.errors.requiredMissing or whitespace only.
orders.form.errors.tooLongOver the max length for that field.
orders.form.errors.phoneInvalidNot a valid Moroccan number.