Alterplay / APValidators

Codeless solution for form validation in iOS!
https://cocoapods.org/pods/APValidators
MIT License
131 stars 18 forks source link

Suggestions #2

Closed BrunoMiguens closed 8 years ago

BrunoMiguens commented 8 years ago

Hi,

I'm using APValidator on a project and i think my suggestions could be a good improvement, correct me if i'm wrong.

1 - APCompoundValidator could be able to manage many outlets, for example if i have 2 password textfields it would be perfect if i just add those textfield to the same compound (right now i need to create a compound for each validator).

2 - APRequiredValidator it would be perfect if i could add the minimum number of characters (right now APRequiredValidator only check if the string is empty.).

3 - If i had a required validator and a email validator in the same textfield, the required validator should be a higher priority, so, if the validations pass the required validator, that means the textfield isn't empty, so i will go to another validator if exists. Now i have exactly that example with an empty string on textfield and they give the error message of email validator when they should give me a required validator message.

Thank you for your time.

NickolaySheika commented 8 years ago

Hi,

Excuse me for late response. Thank you for your suggestions.

1 - APEqualStringValidator is made exactly for case with 2 passwords. You can attach second control to it. Please take a look at example app for more info. 2 - Please use APCharactersCountValidator. It has minCount and maxCount. 3 - You cannot attach more than one validator to textfield. I think you have a required validator and an email validator attached to APCompoundValidator's validators property, and then only it attached to textfield. Correct me if i'm wrong. So in this case APCompoundValidator's errorMessage returns error message of first invalid validator. As validators property is simple IBOutletCollection you can adjust priority simply by connecting validators in correct order. So just connect your required validator first and email validator after it. Another option will be to iterate through validators property and find failed validator.