Skip to content

Commit

Permalink
feat: added check for valid string regex
Browse files Browse the repository at this point in the history
  • Loading branch information
roger-king committed Jan 15, 2021
1 parent 6428dc7 commit f22c562
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions prompts/multi_input.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@ func (m *MultiInput) Run() (string, error) {
prompt := promptui.Prompt{
Label: m.Label,
Validate: func(input string) error {
if matched, err := regexp.Match(m.ValidString, []byte(input)); err != nil || !matched {
return errors.New("not a valid input")
if len(m.ValidString) > 0 {
if matched, err := regexp.Match(m.ValidString, []byte(input)); err != nil || !matched {
return errors.New("not a valid input")
}
}

return nil
Expand Down

0 comments on commit f22c562

Please sign in to comment.