feat: support optionally passing kong.Context to Validate()

Fixes #340
This commit is contained in:
Alec Thomas
2024-11-03 14:14:55 +11:00
parent 64229c9fe7
commit 1b9d57eec1
3 changed files with 33 additions and 4 deletions
+7 -2
View File
@@ -663,8 +663,7 @@ func main() {
## Validation
Kong does validation on the structure of a command-line, but also supports
extensible validation. Any node in the tree may implement the following
interface:
extensible validation. Any node in the tree may implement either of the following interfaces:
```go
type Validatable interface {
@@ -672,6 +671,12 @@ type Validatable interface {
}
```
```go
type Validatable interface {
Validate(kctx *kong.Context) error
}
```
If one of these nodes is in the active command-line it will be called during
normal validation.