For example I had a task late afternoon to validate emails that are stored in an Array. I original stored all emails as strings but due to way the Rails Mailer works and the needs of the application, the emails are now being collected using CSV(separate by commas) in a string. I am easily able to split that string using split(",") and serializing that into an array. I am also handling single emails by converting them using the Rails method Array.wrap(). Those 2 methods could be blog post in their selves but I am opting to just explain my next issue.
The trouble with storing the emails in an Array is that it broke all my email validations, which does not check a string of emails, I now am tasked with testing the validations by hand, after discovering that the Active Validator only validates strings.
Validate an array of emails.
emails: ["ilikerobot[at]gmail.com, hello[at]briandouglas.me"]
emails.split(",")
emails: ["ilikerobot[at]gmail.com", "hello[at]briandouglas.me"]
With this being my first major case where Rails couldn't do what, I am considering looking at the Active Validator to see if I can contribute to it and add this functionality, but it might be better as a gem. I am sure it would take longer than a night to implement but it could be a cool challenge to create my first gem and this idea seems simple enough.
My first implementation:
My final implementation *after peer review, it turned out I wrote too much code just to check for the validation of an email :)
I also did the same validation in Javascript, on the client-side.
Just previewed thanks for the information, wanna advise another great tool - https://www.mailcheck.co/ it's linked to social profiles less to direct SMPT checks.
ReplyDelete