Skip to content

Commit

Permalink
command/ValidateArgs: check ValidArgs regardless of Args being nil
Browse files Browse the repository at this point in the history
  • Loading branch information
umarcor committed Mar 25, 2022
1 parent dbe9027 commit effd9ba
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions command.go
Expand Up @@ -1006,15 +1006,16 @@ func (c *Command) ExecuteC() (cmd *Command, err error) {
return cmd, err
}

// ValidateArgs returns an error if any positional args are not in
// the `ValidArgs` field of `Command`
// ValidateArgs returns an error if any positional args are not in the
// `ValidArgs` field of `Command`. Then, run the `Args` validator, if
// specified.
func (c *Command) ValidateArgs(args []string) error {
if c.Args == nil {
return nil
}
if err := validateArgs(c, args); err != nil {
return err
}
if c.Args == nil {
return nil
}
return c.Args(c, args)
}

Expand Down

0 comments on commit effd9ba

Please sign in to comment.