Hi all,
I''m hoping to stir the Rails pot a little bit here, so please go easy
with me ;-)
Regular Expressions is the most densely inhumane language construct
ever invented in any ''civilisation'', and the fact that we
still have
to dirty our minds with this in Rails is something that (sh/c)ould
ideally be corrected in Rails (preferably before the release of 1.2
(?)) or in the form of a plugin.
A very common scenario in Rails models are:
validates_format_of :name,
:with => [ only characters that are commonly found in Names,
ie: NOT {^%$([]\/><?;* ) ]
validates_format_of :email,
:with => [ valid email format & characters ]
validates_format_of :url,
:with => [ valid url format & characters ]
validates_format_of :basic_text_block,
:with => [ only letters, numbers, punctuations and spaces,
but NO HTML or code characters ]
validates_format_of :basic_text_with_textile_block,
:with => [ textile approved characters ]
OK, you get the picture, now imagine if it was working like this:
validates_format_of :name,
:with => :basic_safe_text # naming could be different,
but...
validates_format_of :email,
:with => :email_format
validates_format_of :url,
:with => :url_format
validates_format_of : basic_text_block,
:with => :basic_text_block_format
validates_format_of :basic_text_with_textile_block,
:with => : basic_text_with_textile_block_format
or
validates_format_of :text,
:included_chars => %w(a-zA-Z0-9 -'';) # some method for
specifying which chars we wish to accept
:excluded_chars => %w( * & % $ £ ( ) ) # some method for
specifying which chars we wish to exclude
Now that would result in a collective DRY process that would save
thousands of programming hours, be the highlight of a Steve Jobs/DHH
special event, as well as improve the safety and security of
countless rails apps.
Rails have removed the ''ugliness'' of SQL already, so why not
basic
commonly used Regexp stuff as well ??
IF this is NOT deemed to be valuable, could some kind soul out there
create a single resource page with commonly used RUBY (!!!) regexp
versions along the lines outlined above ??
And yes, I have all the Ruby/Rails books, and know all the sites out
there, but my brain still struggles with the idiotic language called
Regular Expressions, and I''m severely fed up with it, so I''m
hoping
to be helped, and I know I''m not the only one out there with the same
problems!
So IF Regexp is dead easy for you, then please don''t complain at my
stupidity, but rather help out and provide clear simple examples that
follows along the lines above. You are doing the WORLD a favour then!
Kind regards,
Mats
----
"TextMate, coding with an incredible sense of joy and ease"
- www.macromates.com -
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk
-~----------~----~----~----~------~----~------~--~---