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