judgegem / judge

Client-side form validation for Rails
MIT License
256 stars 41 forks source link

regex and l18n problems #73

Open be4i opened 8 years ago

be4i commented 8 years ago

Hello, i love the gem thank you for making it its exactly what i needed.I am using authlogic gem and the email address of the users is validated by it, in ruby the regex for it its working fine but in javascript the judge its removing the insensitive modifier and the validation its always invalid.This is the expression "/^[A-Z0-9_.&%+-']+@(?:[A-Z0-9-]+.)+(?:[A-Z]{2,13})$/i", if you can give me some workaround it will be appreciated.The second problem is when i add expose attributes into the judge initializer my l18n config is reset to english when i have set the default locale to bulgarian.

joecorcoran commented 8 years ago

Trying to remember why I decided a long time ago that the only modifier that Judge could support was m and not i. I really don't know. Maybe that should be fixed!

In the meantime, you can just override your regexp so that your character classes also include the lower case, e.g. [A-Za-z0-9]. Seems like it would be pretty easy to do, based on this.

I don't understand the second problem. Can you explain it further?

be4i commented 8 years ago

Thank you for your answer, for the second problem i have this code in my "config/application.rb" file config.i18n.default_locale = :bg and everything is working as expected.But when i add this code to the "initializers/judge.rb" file Judge.configure do expose User, :email end, all the translations are in English and my bg.yml content is ignored

joecorcoran commented 8 years ago

Ah okay. That sounds bad! I'll try and look into this later.

be4i commented 8 years ago

And the strange part is that the locale change is not limited to the model that i am exposing but across the whole application