Skip to content

Commit 67b547c

Browse files
committed
...
1 parent fb76a6c commit 67b547c

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

README.md

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,21 +38,27 @@ type IntrospectorV2 interface {
3838
// return value is true.
3939
Validate(Validator) (error, bool)
4040
}
41+
42+
type IntrospectorV3 interface {
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+
}
4148
```
4249

4350
When validating a type that conforms to either of these interfaces, Go Validate will invoke the `Validate` method first, before checking individual fields.
4451

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.
4653

4754
## Supported Tags
4855
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.
4956

5057
| Tag | Description |
5158
|-----|-------------|
5259
| `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. |
5662

5763
You may change the name of these tags by either using `NewWithConfig` or providing config options to `New` (see below).
5864

0 commit comments

Comments
 (0)