SkyFloatingLabelTextField
SkyFloatingLabelTextField copied to clipboard
Adding validation
Hello!
I would like to enhance the project.
I have a suggestion - what if we add a validation?
We can have several default validations:
- only numbers
- check if valid email
- ...
And then we can have a custom validation in which the user can add his own regex as a parameter to function.
What do you guys think about idea?
Any suggestions/ideas are more than welcome.
This is a great idea, I'm sure most of those who implemented SkyFloatingLabelTextField are already running few validations on their code. I think that the regex approached is also a good idea. there are few projects for more complex validations such as credit-card or phone numbers where simple regex won't be enough but for the simpler cases it will work.
That is what I do now. I have validation code in my project.
But when you use SkyFloatingLabelTextField in many View Controllers you have to make some sort of manager that will have validation logic or you must implement validation logic in any View Controller.
So I was thinking why not put that logic in SkyFloatingLabelTextField. Then the validation will be like one liner in your code.
Yeah this is definitely something that could be worth considering. We need to keep ability to use UITextFieldDelegate
directly in combintation with validations however.
Something like this with a few built in and the ability to add new ones yourself maybe?
protocol Validator {
bool isValidForValue(value)
}