Skip to content

Support passing a custom formatter to TextField #1528

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

Merged
merged 4 commits into from
Oct 4, 2021

Conversation

ethanshar
Copy link
Collaborator

Description

Support passing a custom formatter to TextField

Changelog

Support passing a custom formatter to TextField

* Support passing a static validation message regardless to the validate prop

* Fix typing

* Fix validate typing
@ethanshar ethanshar added the Important for Next Release PR that must be included in the release version label Sep 9, 2021
@ethanshar ethanshar requested a review from mendyEdri September 9, 2021 13:46
/**
* Custom formatter for the input value (used only when input if not focused)
*/
formatter?: (value?: string) => string;
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it possible for the formatter to return undefined?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Do you mean whether we should have the following signature?
(value?: string) => string | undefined;?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, in second thought, when you format something and it's not correct, you return the same value + an error, right?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Well it's really up to the user implementation.. they can do whatever..
Technically, we can support returning undefined since it's a valid value for TextField.
I'll change it

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Fixed

@ethanshar ethanshar requested a review from mendyEdri October 4, 2021 11:40
@mendyEdri mendyEdri merged commit bd7b6ed into master Oct 4, 2021
@ethanshar ethanshar deleted the feat/TextFieldFormatter branch November 30, 2021 08:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Important for Next Release PR that must be included in the release version
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants