Closed codedge closed 1 year ago
Hi! So the key for this example is in the paragraph above that says:
When validating an iterable (map, slice, or array), whose element type implements the validation.Validatable interface, the validation.Validate method will call the Validate method of every non-nil element.
Basically what they're saying there is that Address
struct has a Validate() error
method implementation that will validate the struct. You can see the example for that here: https://github.com/invopop/validation#validating-a-struct
I hope that's clearer!
Hey,
I struggeling with the section Maps/Slices/Arrays of Validatables as I cannot see where the rules are set.
In this example how do you pass the rule for the city field, f. ex. to validate
required
. Could you enrich this example with the rules that are indicated in the errors0: (City: cannot be blank; Street: cannot be blank.); 2: (Street: cannot be blank; Zip: must be in a valid format.).
?Thanks!