SkyFloatingLabelTextField icon indicating copy to clipboard operation
SkyFloatingLabelTextField copied to clipboard

Adding validation

Open Matic1993 opened this issue 7 years ago • 3 comments

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.

Matic1993 avatar May 15 '17 06:05 Matic1993

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.

pichirichi avatar May 15 '17 06:05 pichirichi

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.

Matic1993 avatar May 15 '17 06:05 Matic1993

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)
}

k0nserv avatar May 22 '17 03:05 k0nserv