validation object to any question to enforce the format of the answer. Validation runs in two places: during the call (triggering a retry if the answer doesn’t match), and when you manually correct an answer via PATCH /api/v1/agents/{agent_id}/conversations/{conversation_id}/form_data.
Validation object structure
Add avalidation key to any question object and set its type to one of the rule names below. Some rules accept additional parameters in a rules sub-object.
date), you can omit rules entirely.
Available rules
phone_number — 10-digit Indian phone number
phone_number — 10-digit Indian phone number
Validates that the answer is a 10-digit Indian mobile or landline number.Parameters:
Behaviour:
- Strips leading
+91,91, or0prefixes before counting digits. - Rejects numbers where all digits are the same (e.g.,
9999999999).
min_length — minimum character count
min_length — minimum character count
Requires the answer to be at least a given number of characters long.Parameters:
exact_num_digits — exact digit count
exact_num_digits — exact digit count
Requires the answer to contain exactly the specified number of digits, ignoring non-digit characters.Parameters:
number_range — numeric range
number_range — numeric range
Requires the numeric answer to fall within a specified range. You can supply one or both bounds.Parameters:
date — valid DD-MM-YYYY date
date — valid DD-MM-YYYY date
Requires the answer to be a valid calendar date in
DD-MM-YYYY format.Parameters: None.date_format — alias for date
date_format — alias for date
An alias for the
date rule. Behaves identically — use whichever name feels clearer in your configuration.Parameters: None.date_today_or_past — today or earlier
date_today_or_past — today or earlier
Requires the answer to be a valid
DD-MM-YYYY date that is today or in the past. Useful for fields like date of birth or symptom onset date.Parameters: None.date_future — strictly after today
date_future — strictly after today
Requires the answer to be a valid
DD-MM-YYYY date that is after today. Useful for appointment or follow-up dates.Parameters: None.regex — custom regular expression
regex — custom regular expression
Validates the answer against a regular expression you define. Include a
message to tell the agent (and the caller) what format is expected.Parameters:free_text — natural-language LLM rule
free_text — natural-language LLM rule
Describes a validation rule in plain English, enforced by the LLM during the call. Use this for rules that are difficult to express as a pattern — for example, requiring a valid Indian state name.Parameters:
Failure response
When validation fails during aPATCH /api/v1/agents/{agent_id}/conversations/{conversation_id}/form_data request, you receive HTTP 400. The response body identifies every field that failed:
object
A map of field names to failure details. Each entry describes one field that failed validation.
Nothing is saved if any field fails validation. Fix all reported fields and resubmit the entire patch.