Forum: Ruby on Rails Validation on special characters

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
8d4c3605bb2853f5088f8719d352f3cd?d=identicon&s=25 Clem Rock (clemrock)
on 2007-07-04 16:33
(Received via mailing list)
Hello,

    I'm trying to make a validation that catches special latin chars
that
cause Mysql errors.

Here's what I've been trying so far:

validates_format_of :title, :with=>/\A[^#]/, :message=>'must not start
with
a "#"', :if => Proc.new {|page| page.title && page.title.size > 0 }

  validates_exclusion_of :title, :in => 'π ≤ ≥ ∫ √ ≈ Ω ∞ ≠ ∑ 
∂ ∆ ˙ ˚',
:message => "Title contains invalid characters"

When I throw these characters into the textfield, they aren't dectected
and
the sql error is thrown.


--
View this message in context:
http://www.nabble.com/Validation-on-special-charac...
Sent from the RubyOnRails Users mailing list archive at Nabble.com.
This topic is locked and can not be replied to.