Wher to find regexp for email validation within simple_form

148 views
Skip to first unread message

Jonathan RAMBY

unread,
May 24, 2011, 9:13:07 AM5/24/11
to SimpleForm
Hi all,

I am testing a newsletter inscription form on my project:

- Given I am on rails 3.0.7; ruby 1.9.2-p136
- I have a model validation written like this:
validates_format_of :email, :with => /\A([^@\s]+)@((?:[-a-z0-9]+\.)+
[a-z]{2,})\Z/i
But it don't semmes to be used by simple_form at all....

- Then I test an email like "email" in the newsletter[email] field and
it is recognized to be a wrong email format.
- And when I try "test@email" (still invalid) which is not recognized
by simple form validation as a wrong email format.

What's wrong in my process?

Thank you all for answers

Carlos Antonio da Silva

unread,
May 24, 2011, 10:02:31 PM5/24/11
to plataformate...@googlegroups.com
This is not SimpleForm, this is probably your validation that is somehow wrong.

Try validating your model using the Rails console, and you will see your model is considered valid with an email like "test@email". SimpleForm does not validate anything, it just makes use of the errors in the object to show them in a nicer way.
--
At.
Carlos A. da Silva

Jonathan RAMBY

unread,
May 25, 2011, 2:06:01 AM5/25/11
to plataformate...@googlegroups.com
Hello,

Thanks for your answer, I was confused by HTML 5 validation ability by the input type email, I thought the instant validation came from simple_form... I had to ad it in my model and really validate the form to se the performance of my model's validation.

Thank you again for the answer.

Jonathan.

2011/5/25 Carlos Antonio da Silva <carlosanto...@gmail.com>



--
RAMBININTSOA Jonathan.
"Mais SI vous êtes conduits par l'Esprit, vous n'êtes plus sous la Loi." (Gal. 5:18)
-------------------------------------------------------------------------------------------------------------------------------------------------------
http://wizikart.110mb.com
webdev...@gmail.com
261 (0) 33 40 849 22


Reply all
Reply to author
Forward
0 new messages