Command is validated before flags
Author: maratoriCreated Jun 26, 2026Updated Jun 26, 2026
Command is validated before its flags. I expect command validation to operate on already-validated flags. Here is a simple demonstration: https://go.dev/play/p/fk5EOSl7MuN
type CLI struct {
Command Command `cmd:""`
}
type Command struct {
Flag Flag
}
func (Command) Validate() error {
fmt.Println("validate command")
return nil
}
type Flag string
func (Flag) Validate() error {
fmt.Println("validate flag")
return nil
}
func main() {
kong.Must(&CLI{}).Parse([]string{"command", "--flag", "value"})
// validate command
// validate flag
}
Source: alecthomas/kong