Skip to content

Quick Example

Here is a quick example:

package main
import v "github.com/cohesivestack/valgo"
func main() {
val := v.
Is(v.String("Bob", "full_name").Not().Blank().OfLengthBetween(4, 20)).
Is(v.Number(17, "age").GreaterThan(18))
if !val.Valid() {
out, _ := json.MarshalIndent(val.Error(), "", " ")
fmt.Println(string(out))
}
}

output:

{
"age": [
"Age must be greater than \"18\""
],
"full_name": [
"Full name must have a length between \"4\" and \"20\""
]
}