Skip to content

Conversation

dopey
Copy link
Contributor

@dopey dopey commented Feb 26, 2025

No description provided.

ui/options.go Outdated
Comment on lines 148 to 150
func WithValidateMinLen(length int) Option {
return WithValidateFunc(MinLen(length))
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would use WithValidateMinLength and MinLength instead of MinLen. If we want to shorten it, we can name it WithMinLength.

ui/validators.go Outdated

// MinLen is a validation function that checks for a minimum length.
// An input length <= 0 indicates that the check should not be performed.
func MinLen(length int) promptui.ValidateFunc {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

ui/validators.go Outdated
Comment on lines 85 to 86
re := regexp.MustCompile(`\s+`)
next := re.ReplaceAllString(s, "")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please no, you can use strings.TrimSpace(s).

Copy link
Contributor

@maraino maraino Feb 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

or perhaps just strings.TrimRightFunc(s, unicode.IsSpace) as we use in other places.

@dopey dopey requested a review from maraino February 27, 2025 07:02
- MinLen -> MinLength
- regex -> strings.TrimSpace
@dopey dopey merged commit 3977fe0 into main Feb 27, 2025
10 checks passed
@dopey dopey deleted the max/minlen branch February 27, 2025 18:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants