Field Validation

Reusable validation for flow forms and partner backends.

Validate one field

POST /api/v1/validate/field

{
  "field": {
    "key": "email",
    "type": "email",
    "label": "E-mail",
    "required": true
  },
  "value": "not-an-email"
}

Response

{
  "ok": false,
  "key": "email",
  "value": null,
  "error": "Adresse e-mail invalide.",
  "code": "format"
}

Shorthand

{
  "type": "phone",
  "key": "phone",
  "value": "+228XXXXXXXX"
}

Validate a form

POST /api/v1/validate/form

{
  "fields": [
    { "key": "full_name", "type": "text", "label": "Nom", "required": true },
    { "key": "email", "type": "email", "label": "E-mail", "required": false },
    { "key": "phone", "type": "phone", "label": "Téléphone", "required": true }
  ],
  "values": {
    "full_name": "Ama",
    "email": "[email protected]",
    "phone": "+22890000000"
  }
}
  • 200 when ok: true
  • 422 when validation fails (the body always includes errors)
{
  "ok": false,
  "values": {},
  "errors": {
    "email": "Adresse e-mail invalide."
  },
  "error_list": [
    { "key": "email", "code": "format", "error": "Adresse e-mail invalide.", "label": "E-mail" }
  ],
  "first_error": "Adresse e-mail invalide."
}

Supported field types

typeRules
textrequired, minimum/maximum length, optional regex
emailRFC-style email address
phoneE.164 after normalization (+…)
number / integernumeric; optional minimum/maximum
dateYYYY-MM-DD
booleanyes/no
selectvalue must exist in options[].id

Custom field rules

{
  "key": "nif",
  "type": "text",
  "required": true,
  "validation_regex": "^[A-Z0-9-]{6,20}$",
  "validation_message": "NIF invalide",
  "min_length": 6,
  "max_length": 20
}

Client JWT variants

End-user apps can call:

  • POST /api/v1/me/validate/field
  • POST /api/v1/me/validate/form

The request body has the same shape and is authenticated with the user's Bearer token.