SwiftValidatorCommunity / SwiftValidator

A rule-based validation library for Swift
MIT License
1.44k stars 378 forks source link

Add support for UIViews other than UITextField #112

Open davepatterson opened 8 years ago

davepatterson commented 8 years ago

@glaucocustodio and @dadalar,

I understand that both of you have each proposed ways to go about extending this library beyond UITextField. This is definitely something that I'm too interested in. In fact, the only thing that kept me from merging your PR @glaucocustodio was your lack of code coverage. Tonight, I intend to read through your proposal @dadalar. In the meantime, I'm welcome to any comparative analyses of the two PRs either of you care to provide.

Dave

dadalar commented 8 years ago

First of all, no matter how, it would be a major version update with breaking changes. I tried to keep it minimum though.

Current structure of SwiftValidator is very limitive because it depends on UITextField class. @glaucocustodio's pr is about adding supprt for more classes. For me, it's still limitive. Not only you need to make changes on the library if you want to extend with more classes, it'll also pile up on the variables and function parameters. The more Swift way to do it is using protocols. With my solution, anyone can extend their own classes and make it Validatable. It doesn't even have to be a UIView.

glaucocustodio commented 8 years ago

I can keep improving my PR, but I need to know if you intend to merge it or not (I don't want spend my time in vain). Given this is OSS, it is supposed to be improved with time. @davepatterson

davepatterson commented 8 years ago

@glaucocustodio I understand where you're coming from but I must admit that your PR is a bit clunky and contains a fair amount of replicated source code. I'm going to have to say that I'm siding with @dadalar as his protocol based approach is more Swift-esque. If you have time, I recommend that you check it out #111 😄

glaucocustodio commented 8 years ago

@dadalar's approach seems much better. I tried to use protocols, but I failed. I think would be nice if he could write more extensions beyond UITextField's (extension UITextField: Validatable).

davepatterson commented 8 years ago

Definitely. I already have a few extensions. I am going to submit a PR after I merged @dadalar's. I was just waiting for your feedback first @glaucocustodio.

glaucocustodio commented 8 years ago

Lets merge it! 🎉