Ruby on Rails Friday, June 28, 2013

Manoj M. <lists@ruby-forum.com> wrote:
> Hi
> anybody help me to find suitable validation way for Hash_Tag, My need is
> user should only type hash_tag like below format.
> a) #sports
> b) #sports,#news

Did you really mean "Client Side Validation" as you have in your
Subject: line? That means JavaScript, not ActiveRecord validations?
Even if you do use Client Side validation, you really need to do Server
Side as well to guard against hacks. Read about Server Side here:

http://guides.rubyonrails.org/active_record_validations.html

Follow Robert's advice as well and learn some regular expression
magic. You'll need it for either side.

I'm wondering altogether though, why the need to validate this? If the
user is typing a stream of text, they may or may not wish to include #
at some point other than as a hash tag; I think perhaps you maybe just
want to extract the hash tags that match your spec, rather than declare
the input invalid? I'm just speculating here, I obviously don't know
what your application is trying to do. It's the concept of hash tags
from twitter and now other services that I'm thinking of; a way to
denote a specific key word to search on in a stream of text.

Anyway, more code/design/info is needed to help more, I think.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/51ce5074.2576320a.0e85.52cc%40mx.google.com.
For more options, visit https://groups.google.com/groups/opt_out.

No comments:

Post a Comment