Skip to content

Commit 22aaa55

Browse files
joeybloggsjoeybloggs
authored andcommitted
add dive documentation
for #78
1 parent 200a5b4 commit 22aaa55

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

doc.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,25 @@ Here is a list of the current built in validators:
173173
such as min or max won't run, but if a value is set validation will run.
174174
(Usage: omitempty)
175175
176+
dive
177+
This tells the validator to dive into a slice, array or map and validate that
178+
level of the slice, array or map with the validation tags that follow.
179+
Multidimensional nesting is also supported, each level you with to dive will
180+
require another dive tag. (Usage: dive)
181+
Example: [][]string with validation tag "gt=0,dive,len=1,dive,required"
182+
gt=0 will be applied to []
183+
len=1 will be applied to []string
184+
required will be applied to string
185+
Example2: [][]string with validation tag "gt=0,dive,dive,required"
186+
gt=0 will be applied to []
187+
[]string will be spared validation
188+
required will be applied to string
189+
NOTE: in Example2 if the required validation failed, but all others passed
190+
the hierarchy of FieldError's in the middle with have their IsPlaceHolder field
191+
set to true. If a FieldError has IsSliceOrMap=true or IsMap=true then the
192+
FieldError is a Slice or Map field and if IsPlaceHolder=true then contains errors
193+
within its SliceOrArrayErrs or MapErrs fields.
194+
176195
required
177196
This validates that the value is not the data types default value.
178197
For numbers ensures value is not zero. For strings ensures value is

0 commit comments

Comments
 (0)