Skip to content

Added FormItem Validation#301

Open
mikeschinkel wants to merge 2 commits intorivo:masterfrom
mikeschinkel:form_validation
Open

Added FormItem Validation#301
mikeschinkel wants to merge 2 commits intorivo:masterfrom
mikeschinkel:form_validation

Conversation

@mikeschinkel
Copy link
Copy Markdown
Contributor

This PR includes the commits for #300 because it is too hard to use without the FormItemArgs (IMO.)

This adds a .valid property and a .SetValidateFunc to each of InputField, PasswordField, DropDown and Checkbox structs.

It also adds a ValidatePrimitive(Primitive,EventKey) method to Application and calls that method inside <application>.Run() just before invoking the primitive's InputHandler().

It will only call the validation callback when event.Key() is one of
tcell.KeyEnter, tcell.KeyTab, tcell.KeyBacktab or tcell.KeyEscape.

If the callback returns false, it bypasses the input handler and keeps focus on the just now invalidated field.

Please consider accepting this update.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant