File tree 2 files changed +12
-3
lines changed
2 files changed +12
-3
lines changed Original file line number Diff line number Diff line change @@ -24,8 +24,17 @@ type Validator[T pflag.Value] struct {
24
24
validate func (T ) error
25
25
}
26
26
27
- func Validate [T pflag.Value ](opt T , validate func (value T ) error ) * Validator [T ] {
28
- return & Validator [T ]{Value : opt , validate : validate }
27
+ func Validate [T pflag.Value ](opt T , validate ... func (value T ) error ) * Validator [T ] {
28
+ return & Validator [T ]{Value : opt , validate : func (value T ) error {
29
+ // Run all validate functions
30
+ for _ , v := range validate {
31
+ err := v (value )
32
+ if err != nil {
33
+ return err
34
+ }
35
+ }
36
+ return nil
37
+ }}
29
38
}
30
39
31
40
func (i * Validator [T ]) String () string {
Original file line number Diff line number Diff line change @@ -236,7 +236,7 @@ func (r *RootCmd) createProxy() *clibase.Cmd {
236
236
formatter = newUpdateProxyResponseFormatter ()
237
237
)
238
238
validateIcon := func (s * clibase.String ) error {
239
- if ! (strings .HasPrefix (s .Value (), "/emojis/" ) || strings .HasPrefix (s , "http" )) {
239
+ if ! (strings .HasPrefix (s .Value (), "/emojis/" ) || strings .HasPrefix (s . Value () , "http" )) {
240
240
return xerrors .New ("icon must be a relative path to an emoji or a publicly hosted image URL" )
241
241
}
242
242
return nil
You can’t perform that action at this time.
0 commit comments