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
Copy file name to clipboardExpand all lines: README.md
+10-4Lines changed: 10 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -38,21 +38,27 @@ type IntrospectorV2 interface {
38
38
// return value is true.
39
39
Validate(Validator) (error, bool)
40
40
}
41
+
42
+
typeIntrospectorV3interface {
43
+
// Perform custom validation of the receiver and then perform
44
+
// checks that are defined on individual fields if the second
45
+
// return value is true.
46
+
Validate(Validator, Context) (error, bool)
47
+
}
41
48
```
42
49
43
50
When validating a type that conforms to either of these interfaces, Go Validate will invoke the `Validate` method first, before checking individual fields.
44
51
45
-
If the type implements `IntrospectorV2` and `Validate` returns `true` for the second return value, Go Validate will continue on to validate individual fields. If `false` is returned or if the type implements `IntrospectorV1` instead, the individual fields will not be automatically validated.
52
+
If the type implements `IntrospectorV2`or `IntrospectorV3`and `Validate` returns `true` for the second return value, Go Validate will continue on to validate individual fields. If `false` is returned or if the type implements `IntrospectorV1` instead, the individual fields will not be automatically validated.
46
53
47
54
## Supported Tags
48
55
Struct tags are used to control how Go Validate does its validation. The following tags are supported, and their names can be changed if you like.
49
56
50
57
| Tag | Description |
51
58
|-----|-------------|
52
59
|`check`| The expression that will be evaluated. It is common to use different tag names for different "modes". See below. |
53
-
|`invalid`| The error message that should be used when `check` fails. You may omit this if you don't mind a generic message. |
54
-
|`json`| The name of the field. |
55
-
60
+
|`invalid`| The error message that should be used when `check` fails. You may omit this if you don't mind a generic message and you may specify `-` if you want no error to be reported when validation fails. This can be used when a sub-type is expected to generate all the errors required. |
61
+
|`json`| The name of the field, which will be referenced in errors. |
56
62
57
63
You may change the name of these tags by either using `NewWithConfig` or providing config options to `New` (see below).
0 commit comments