Skip to content

Overview

This content is for v0.7. Switch to the latest version for up-to-date documentation.

Validators hold a value and a list of rules to evaluate.

If you omit a name, Valgo generates one (e.g. value_0).

val := v.New(v.String("").Empty())

Prefer passing a stable field name (and optionally a human-friendly title):

val := v.New(v.String("", "company_name").Not().Empty())
val := v.New(v.String("", "company_name", "Customer").Not().Empty())

Not() inverts the next rule.

valid := v.Is(v.Number(0).Not().Zero()).Valid()