Skip to content

Boolean Validators for Go

Bool() supports True(), False(), EqualTo(), InSlice(), and Passing().

v.Is(v.Bool(true, "active").True())
v.Is(v.Bool(false, "active").Not().False())
v.Is(v.Bool(true, "enabled").EqualTo(true))

BoolP() accepts *bool. Its callback receives the pointer, and it adds Nil() and FalseOrNil().

var active *bool
v.Is(v.BoolP(active, "active").Nil())
v.Is(v.BoolP(active, "active").FalseOrNil())