Skip to main content

Validation Showcase

This guide demonstrates how to build reliable forms with Ziva: cover every built-in validator, assemble validation chains, and plug in external checks.

Queue with all built-in validators

Each task triggers its validator after the user presses Enter. When validation fails, the TUI shows the error and keeps the task focused until the value matches the rules.

Custom validation chain

External validator example

Use a FuncTask after collecting input if you need to call an external service and display the outcome (success, warning, retry hints) inside the TUI.

Quick tips

  • Keep Description() human-friendly — Ziva shows it near the input field.
  • Combine WithAllowEmpty(true) with validators that handle empty strings correctly.
  • Break long forms into several queues; it simplifies returning to the problem field.
  • Write unit tests for elaborate validators — they are plain Go code.
Head over to the best practices page to see how these building blocks fit together in real projects.