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

ValidatorControlDelegate is only possible when using ValidatorTextField #54

Open
markst opened this issue Mar 22, 2017 · 5 comments
Open
Labels

Comments

@markst
Copy link

markst commented Mar 22, 2017

I use https://github.com/CosmicMind/Material
Which has it's own styled UITextField subclasses.

My subclassed text field implements ValidatorControl protocol.

class ValidationTextField: ErrorTextField, ValidatorControl

It would be good if I could use ValidatorControlDelegate when using other classes besides the provided ValidatorTextField.

@ghost
Copy link

ghost commented Mar 22, 2017

The ValidatorControlDelegate does not require the use of ValidatorTextField, only a class that conforms to the ValidatorControl protocol. Your custom ValidationTextField does this. Are you having difficulty building an implementation using the ValidatorControlDelegate that uses your ValidationTextField?

Reference:

@ghost ghost added the question label Mar 22, 2017
@markst
Copy link
Author

markst commented Mar 22, 2017

@aamctustwo thanks for response, I'm not sure I'm convinced.

The logic for ValidatorControlDelegate.validatorControlDidChange is seems to be within the UITextField subclass ValidatorTextField - which relies on subscribing to UITextFieldTextDidChange notification:
https://github.com/ustwo/formvalidator-swift/blob/master/Sources/Controls/ValidatorTextField-UIKit.swift#L73

@ghost
Copy link

ghost commented Mar 22, 2017

You should be able to do something similar with your ValidationTextField. Since ErrorTextField is just a descendant subclass of UITextField ultimately. You may be able to tie into some of CosmicMind Material's other delegates for TextField, but you'd have to investigate that library further.

@markst
Copy link
Author

markst commented Mar 22, 2017

Exactly. In which case how would you feel about exposing ValidatorTextFieldResponder to make this possible without having to duplicate a lot of logic?

@aamctustwo

@ghost
Copy link

ghost commented Mar 23, 2017

As it is originally written, the ValidatorTextFieldResponder and its corresponding implementations for text views and for AppKit were tightly coupled to the core UI component (ValidatorTextField) and never intended to be publicly exposed.

If you'd like to raise a PR with an implementation, I'd be happy to take a look at it.

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

No branches or pull requests

1 participant