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"
}
}
200whenok: true422when validation fails (the body always includeserrors)
{
"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
type | Rules |
|---|---|
text | required, minimum/maximum length, optional regex |
email | RFC-style email address |
phone | E.164 after normalization (+…) |
number / integer | numeric; optional minimum/maximum |
date | YYYY-MM-DD |
boolean | yes/no |
select | value 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/fieldPOST /api/v1/me/validate/form
The request body has the same shape and is authenticated with the user's Bearer token.