You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
#### Activate behavior to require all fields have a validation tag by default
30
+
`SetFieldsRequiredByDefault` causes validation to fail when struct fields do not include validations or are not explicitly marked as exempt (using `valid:"-"` or `valid:"email,optional"`). A good place to activate this is a package init function or the main() function.
type CustomByteArray [6]byte// custom types are supported and can be validated
341
+
342
+
type StructWithCustomByteArray struct {
343
+
ID CustomByteArray `valid:"customByteArrayValidator,customMinLengthValidator"`// multiple custom validators are possible as well and will be evaluated in sequence
switchv:= context.(type) { // this validates a field against the value in another field, i.e. dependent validation
371
+
case StructWithCustomByteArray:
372
+
returnlen(v.ID) >= v.CustomMinLength
373
+
}
374
+
returnfalse
375
+
}))
376
+
```
377
+
275
378
#### Notes
276
379
Documentation is available here: [godoc.org](https://godoc.org/github.com/asaskevich/govalidator).
277
380
Full information about code coverage is also available here: [govalidator on gocover.io](http://gocover.io/github.com/asaskevich/govalidator).
0 commit comments