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

Can we make the error detail for textfields dynamic ? #1017

Closed
swift1022 opened this issue Jan 10, 2018 · 6 comments
Closed

Can we make the error detail for textfields dynamic ? #1017

swift1022 opened this issue Jan 10, 2018 · 6 comments

Comments

@swift1022
Copy link

When the user is typing email : If the email is not in Regex format then it should the error ("invalid") automatically and when the email is again edited in Regex format then the error must be removed automatically while editing. Is it possible to do using this library ??
Just like as shown in screenshots below for Email field :

simulator screen shot - iphone 8 - 2018-01-10 at 21 48 20
simulator screen shot - iphone 8 - 2018-01-10 at 21 49 22

@daniel-jonathan
Copy link
Member

You can do this using the delegation methods associated with the TextField. There is not a validation check for the values added, at least not at the moment. It would be a good feature though, and has been noted prior. I will add a feature request tag to this and make a sample or build it into Material. Thank you!

@adamdahan
Copy link
Contributor

adamdahan commented Jan 19, 2018

@DanielDahan @Maddy10

Just wanted to add my two cents 😄

Validation should live outside of the framework as there are too many types of fields and validations. Ideally you would have a protocol to enable such functionality.

protocol TextFieldValidator {
func validateTextField()
}

protocol EmailTextFieldValidator: TextFieldValidator {}
protocol PhoneTextFieldValidator: TextFieldValidator {}

Then you can conform to your protocol when you need to validate a specific field and implement the validateTextField signature.

This also ensures that you keep your code dry and don't create needless subclasses of TextField.

Let me know if this makes sense - otherwise I can make a sample.

Best!

@daniel-jonathan
Copy link
Member

I agree @adamdahan. Are you suggesting to leave this outside of Material for now?

@OrkhanAlikhanov
Copy link
Contributor

Made PR for this #1082

@OrkhanAlikhanov
Copy link
Contributor

#1082 is merged in, so next release gonna have this feature. For the usage guide see the PR description. Thank you!

@daniel-jonathan
Copy link
Member

I am going to close this issue as the PR is merged in. Let's focus on tomorrow making a release.

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

No branches or pull requests

4 participants