Is(...) function
The Is(...) function allows you to pass one or multiple Validators, each with their respective values and rules for validation. This creates a Validation session, which can be used to validate multiple values.
In the following example, we pass multiple Validators for the full_name, age, and status values to the Is(...) function:
val := v.Is( v.String("Bob", "full_name").Not().Blank().OfLengthBetween(4, 20), v.Number(17, "age").GreaterThan(18), v.String("singl", "status").InSlice([]string{"married", "single"}))
if !val.Valid() { out, _ := json.MarshalIndent(val.Error(), "", " ") fmt.Println(string(out))}output:```json{ "age": [ "Age must be greater than \"18\"" ], "full_name": [ "Full name must have a length between \"4\" and \"20\"" ], "status": [ "Status is not valid" ]}