File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -115,6 +115,11 @@ func (a *Argument) Required(val bool) *Argument {
115115 return a
116116}
117117
118+ func (a * Argument ) Type (val argumentType ) * Argument {
119+ a .argType = val
120+ return a
121+ }
122+
118123// Configures the valid values for an argument
119124func (a * Argument ) ValidateWith (vals []string ) * Argument {
120125 a .validValues = vals
@@ -184,20 +189,28 @@ func (a *Argument) addValidatorFns() {
184189}
185190
186191func (a * Argument ) testValue (val string ) bool {
192+ valueMatch := false
193+ matchCount := 0
194+
195+ if len (a .validValues ) == 0 {
196+ valueMatch = true
197+ }
198+
187199 for _ , v := range a .validValues {
188200 if strings .EqualFold (v , val ) {
189- return true
201+ valueMatch = true
202+ break
190203 }
191204 }
192205
193206 for _ , fn := range a .validatorFns {
194207 err := fn (val )
195208 if err == nil {
196- return true
209+ matchCount ++
197210 }
198211 }
199212
200- return false
213+ return valueMatch && matchCount == len ( a . validatorFns )
201214}
202215
203216func (a * Argument ) hasDefaultValue () bool {
You can’t perform that action at this time.
0 commit comments