Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(textinput): make validation customizable
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
- Loading branch information