themisir / form-validator

Simplest form validation for flutter form widgets
https://pub.dev/packages/form_validator
MIT License
77 stars 39 forks source link

Leverage validators package instead of writing our own regexp #26

Open tlvenn opened 3 years ago

tlvenn commented 3 years ago

Validation of common idioms via regexp is a tricky business and not something you really want to do yourself. For example, the regexp currently being used to validate emails is actually quite simple:

image

If we were to compare it to the one being define in the validators package:

image

Obviously the latter take into account Unicode characters and probably some other quirks. I believe it would be better to simply leverage the validators package instead of trying to come up with regexps on our own that we have to maintain and test.

tlvenn commented 3 years ago

@TheMisir what do you think ? I can open a PR if there is an agreement that is probably a safer path forward.

themisir commented 3 years ago

I don't like depending on 3rd party packages just for a few lines of code actually 😅

tlvenn commented 3 years ago

I understand the sentiment but those few lines of codes are kinda critical to get right and duplicating and maintaining that effort seems kinda pointless. For me this falls into the same realm as Don't roll your own crypto. The above package has zero dependencies, do only 1 thing and seems to do it right and is well maintained as far as I can see.

tlvenn commented 2 years ago

For reference this package seems like an even better candidate, focusing only on email validation without using regexp

https://github.com/fredeil/email-validator.dart