Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add MinLen validator #164

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Add MinLen validator #164

wants to merge 1 commit into from

Conversation

dopey
Copy link
Contributor

@dopey dopey commented Feb 26, 2025

No description provided.

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.


// 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

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.

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