-
Notifications
You must be signed in to change notification settings - Fork 282
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
feat: added Validate
function for textinput
#114
Closed
IllusionMan1212
wants to merge
1
commit into
charmbracelet:master
from
IllusionMan1212:input-validation
Closed
feat: added Validate
function for textinput
#114
IllusionMan1212
wants to merge
1
commit into
charmbracelet:master
from
IllusionMan1212:input-validation
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6663f8b
to
58ad2b5
Compare
muesli
reviewed
Feb 4, 2022
58ad2b5
to
d1b809d
Compare
muesli
reviewed
Feb 5, 2022
muesli
reviewed
Feb 5, 2022
We should also think of a way to notify API-users of validation issues, so they can inform the user of an error in their program. |
Just chiming in that we should definitely validate pasted input too. |
d1b809d
to
45d8dd9
Compare
45d8dd9
to
8a7b2ef
Compare
Updated to accommodate the requested changes |
Merged
Hi @IllusionMan1212, great idea and great work on this PR. |
GabrielNagy
added a commit
to GabrielNagy/bubbles
that referenced
this pull request
Jul 5, 2022
This PR builds upon the excellent work in charmbracelet#167 and charmbracelet#114 and adds a bit more customizability to the feature. Currently, the validation API will completely block text input if the Validate function returns an error. This commit makes this behavior configurable by introducing a ValidateAction which decides how to proceed in case a validation error happens. To preserve backwards compatibility, the default behavior remains unchanged. If ValidateAction is set to AllowInput, the text input error will still be set if needed, but actual input will not be blocked. This is helpful for cases where the user is requested to type an existing system path, and the Validate function keeps asserting this. With the current implementation such a validation is not possible. For example: > / Err: nil > /t Err: /t: No such file or directory > /tm Err: /tm: No such file or directory > /tmp Err: nil
GabrielNagy
added a commit
to GabrielNagy/bubbles
that referenced
this pull request
Jul 5, 2022
This PR builds upon the excellent work in charmbracelet#167 and charmbracelet#114 and adds a bit more customizability to the feature. Currently, the validation API will completely block text input if the Validate function returns an error. This commit makes this behavior configurable by introducing a ValidateAction which decides how to proceed in case a validation error happens. To preserve backwards compatibility, the default behavior remains unchanged. If ValidateAction is set to AllowInput, the text input error will still be set if needed, but actual input will not be blocked. This is helpful for cases where the user is requested to type an existing system path, and the Validate function keeps asserting this. With the current implementation such a validation is not possible. For example: > / Err: nil > /t Err: /t: No such file or directory > /tm Err: /tm: No such file or directory > /tmp Err: nil
GabrielNagy
added a commit
to GabrielNagy/bubbles
that referenced
this pull request
Jul 5, 2022
This PR builds upon the excellent work in charmbracelet#167 and charmbracelet#114 and adds a bit more customizability to the feature. Currently, the validation API will completely block text input if the Validate function returns an error. This commit makes this behavior configurable by introducing a ValidateAction which decides how to proceed in case a validation error happens. To preserve backwards compatibility, the default behavior remains unchanged. If ValidateAction is set to AllowInput, the text input error will still be set if needed, but actual input will not be blocked. This is helpful for cases where the user is requested to type an existing system path, and the Validate function keeps asserting the existence of the path. With the current implementation such a validation is not possible. For example: > / Err: nil > /t Err: /t: No such file or directory > /tm Err: /tm: No such file or directory > /tmp Err: nil
GabrielNagy
added a commit
to GabrielNagy/bubbles
that referenced
this pull request
Aug 18, 2022
This PR builds upon the excellent work in charmbracelet#167 and charmbracelet#114 and adds a bit more customizability to the feature. Currently, the validation API will completely block text input if the Validate function returns an error. This commit makes this behavior configurable by introducing a ValidateAction which decides how to proceed in case a validation error happens. To preserve backwards compatibility, the default behavior remains unchanged. If ValidateAction is set to AllowInput, the text input error will still be set if needed, but actual input will not be blocked. This is helpful for cases where the user is requested to type an existing system path, and the Validate function keeps asserting the existence of the path. With the current implementation such a validation is not possible. For example: > / Err: nil > /t Err: /t: No such file or directory > /tm Err: /tm: No such file or directory > /tmp Err: nil
GabrielNagy
added a commit
to GabrielNagy/bubbles
that referenced
this pull request
Sep 4, 2023
This PR builds upon the excellent work in charmbracelet#167 and charmbracelet#114 and adds a bit more customizability to the feature. Currently, the validation API will completely block text input if the Validate function returns an error. This commit makes a breaking change to the ValidateFunc by returning an additonal bool that indicates whether or not input should be blocked. This is helpful for cases where the user is requested to type an existing system path, and the Validate function keeps asserting the existence of the path. With the current implementation such a validation is not possible. For example: > / Err: nil > /t Err: /t: No such file or directory > /tm Err: /tm: No such file or directory > /tmp Err: nil
GabrielNagy
added a commit
to GabrielNagy/bubbles
that referenced
this pull request
Feb 29, 2024
This PR builds upon the excellent work in charmbracelet#167 and charmbracelet#114 and adds a bit more customizability to the feature. Currently, the validation API will completely block text input if the Validate function returns an error. This commit makes a breaking change to the validate API to no longer block input if this is the case, thus handing this responsibility to the clients. This is helpful for cases where the user is requested to type an existing system path, and the Validate function keeps asserting the existence of the path. With the current implementation such a validation is not possible. For example: > / Err: nil > /t Err: /t: No such file or directory > /tm Err: /tm: No such file or directory > /tmp Err: nil
GabrielNagy
added a commit
to GabrielNagy/bubbles
that referenced
this pull request
Feb 29, 2024
This PR builds upon the excellent work in charmbracelet#167 and charmbracelet#114 and makes a breaking change to the validation API. Currently, validation will completely block text input if the Validate function returns an error. This is now changed so the function no longer blocks input if this is the case, thus handing this responsibility to the clients. This is helpful for cases where the user is requested to type an existing system path, and the Validate function keeps asserting the existence of the path. With the current implementation such a validation is not possible. For example: > / Err: nil > /t Err: /t: No such file or directory > /tm Err: /tm: No such file or directory > /tmp Err: nil
maaslalani
pushed a commit
to GabrielNagy/bubbles
that referenced
this pull request
Mar 13, 2024
This PR builds upon the excellent work in charmbracelet#167 and charmbracelet#114 and makes a breaking change to the validation API. Currently, validation will completely block text input if the Validate function returns an error. This is now changed so the function no longer blocks input if this is the case, thus handing this responsibility to the clients. This is helpful for cases where the user is requested to type an existing system path, and the Validate function keeps asserting the existence of the path. With the current implementation such a validation is not possible. For example: > / Err: nil > /t Err: /t: No such file or directory > /tm Err: /tm: No such file or directory > /tmp Err: nil
maaslalani
added a commit
that referenced
this pull request
Mar 14, 2024
* feat(textinput): do not block input on validation This PR builds upon the excellent work in #167 and #114 and makes a breaking change to the validation API. Currently, validation will completely block text input if the Validate function returns an error. This is now changed so the function no longer blocks input if this is the case, thus handing this responsibility to the clients. This is helpful for cases where the user is requested to type an existing system path, and the Validate function keeps asserting the existence of the path. With the current implementation such a validation is not possible. For example: > / Err: nil > /t Err: /t: No such file or directory > /tm Err: /tm: No such file or directory > /tmp Err: nil * fix: change name --------- Co-authored-by: Maas Lalani <[email protected]>
ReallyLiri
pushed a commit
to ReallyLiri/bubbles
that referenced
this pull request
Jun 13, 2024
* feat(textinput): do not block input on validation This PR builds upon the excellent work in charmbracelet#167 and charmbracelet#114 and makes a breaking change to the validation API. Currently, validation will completely block text input if the Validate function returns an error. This is now changed so the function no longer blocks input if this is the case, thus handing this responsibility to the clients. This is helpful for cases where the user is requested to type an existing system path, and the Validate function keeps asserting the existence of the path. With the current implementation such a validation is not possible. For example: > / Err: nil > /t Err: /t: No such file or directory > /tm Err: /tm: No such file or directory > /tmp Err: nil * fix: change name --------- Co-authored-by: Maas Lalani <[email protected]>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR adds a
Validate
function to thetextinput
bubble to allow for input validation before it's appended to thetextinput
value.3 built-in validators are provided:
ValidateInt
: validates integer input only.ValidateFloat
: validates float input.ValidateBool
: validates boolean-like inputs such asy
,n
,t
,f
,1
,0
(case insensitive)A usage example is provided here: https://gist.github.com/IllusionMan1212/acddb1533790ad6abc6ee23fac6d9709
This does not validate pasted input. But should it?