@@ -1060,27 +1060,14 @@ Validator notes:
10601060 And the best reason, you can submit a pull request and we can keep on
10611061 adding to the validation library of this package!
10621062
1063- Panics
1064-
1065- This package panics when bad input is provided, this is by design, bad code like
1066- that should not make it to production.
1067-
1068- type Test struct {
1069- TestField string `validate:"nonexistantfunction=1"`
1070- }
1071-
1072- t := &Test{
1073- TestField: "Test"
1074- }
1075-
1076- validate.Struct(t) // this will panic
1077-
10781063Non standard validators
10791064
10801065A collection of validation rules that are frequently needed but are more
10811066complex than the ones found in the baked in validators.
1082- A non standard validator must be registered manually using any tag you like.
1083- See below examples of registration and use.
1067+ A non standard validator must be registered manually like you would
1068+ with your own custom validation functions.
1069+
1070+ Example of registration and use:
10841071
10851072 type Test struct {
10861073 TestField string `validate:"yourtag"`
@@ -1091,13 +1078,30 @@ See below examples of registration and use.
10911078 }
10921079
10931080 validate := validator.New()
1094- validate.RegisterValidation("yourtag", validations.ValidatorName)
1081+ validate.RegisterValidation("yourtag", validators.NotBlank)
1082+
1083+ Here is a list of the current non standard validators:
10951084
10961085 NotBlank
10971086 This validates that the value is not blank or with length zero.
10981087 For strings ensures they do not contain only spaces. For channels, maps, slices and arrays
10991088 ensures they don't have zero length. For others, a non empty value is required.
11001089
11011090 Usage: notblank
1091+
1092+ Panics
1093+
1094+ This package panics when bad input is provided, this is by design, bad code like
1095+ that should not make it to production.
1096+
1097+ type Test struct {
1098+ TestField string `validate:"nonexistantfunction=1"`
1099+ }
1100+
1101+ t := &Test{
1102+ TestField: "Test"
1103+ }
1104+
1105+ validate.Struct(t) // this will panic
11021106*/
11031107package validator
0 commit comments