mirror of
https://github.com/securego/gosec.git
synced 2024-12-26 12:35:52 +00:00
25 lines
421 B
Go
25 lines
421 B
Go
package vflag
|
|
|
|
import (
|
|
"errors"
|
|
"strings"
|
|
)
|
|
|
|
// ValidatedFlag cli string type
|
|
type ValidatedFlag struct {
|
|
Value string
|
|
}
|
|
|
|
func (f *ValidatedFlag) String() string {
|
|
return f.Value
|
|
}
|
|
|
|
// Set will be called for flag that is of validateFlag type
|
|
func (f *ValidatedFlag) Set(value string) error {
|
|
if strings.Contains(value, "-") {
|
|
return errors.New("flag value cannot start with -")
|
|
}
|
|
|
|
f.Value = value
|
|
return nil
|
|
}
|