Validation API
Check data against validation rules without saving a submission. Use it to validate a form step by step, or to validate data that never becomes a submission. New to the API? Start with the overview.
Validate Data
POST /api/v1/validate Bronze Plan
Checks the data you send against the rules you send with it. No form is needed.
| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
rules |
body | object | Yes | The rules for each field, by field name. Write a field's rules as a list, or as text with a | between them. |
| Your fields | body | The data to check. Everything in the body besides rules. |
curl -X POST "https://kwesforms.com/api/v1/validate" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-d '{
"rules": {
"name": "required",
"email": "required|email"
},
"name": "John Doe",
"email": "not-an-email"
}'
When every field passes, the status is 200:
{
"valid": true,
"message": "All fields passed validation."
}
When a field fails, the status is 422 and errors has the messages per field:
{
"valid": false,
"errors": {
"email": ["The email must be a valid email address."]
}
}
| Status | Message | Why |
|---|---|---|
400 |
Validation rules must be provided in the request body under the "rules" key. |
rules is missing or empty. |
400 |
These rules are not allowed: exists. |
rules has a rule the API does not run. The message names it. |
Validate Data for a Form
POST /api/v1/validate/{form} Bronze Plan
Checks the data you send against the rules one of your forms already has. A form without rules passes everything.
| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
form |
path | string | Yes | The form's key: the last part of its action address. This call does not take the form's ID. |
| Your fields | body | The data to check. |
curl -X POST "https://kwesforms.com/api/v1/validate/6WtWzzN1A3LnpBML3pqr" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-d '{
"name": "John Doe",
"email": "not-an-email"
}'
The replies are the same as for Validate Data: 200 with "valid": true, or 422 with "valid": false and the errors.
Notice anything wrong in our docs? Let us know.