On Fri, Nov 7, 2008 at 8:39 PM, Sijo Kg <[EMAIL PROTECTED]>
 wrote:

>
> Hi
>   This is not the required solution Suppose the user enters
> [EMAIL PROTECTED]@@ or [EMAIL PROTECTED]@ what happens?  Since we  cant 
> insists
> that there should be value after @  or @@


Use tmail to validate your email :)
It will raise an exception on basically anything except a correct address.

And I would recommend not using an '@' symbol to symbolize anything in an
email address. It is the key component that separates the local from the
domain part of the email address and you will always run into problems.

You can see how here:

http://www.lindsaar.net/2008/4/14/tip-4-detecting-a-valid-email-address

>> require 'tmail'
=> true
>> TMail::Address.parse('[EMAIL PROTECTED]@@')
TMail::SyntaxError: parse error on token "@"
from parser.y:379:in `on_error'
from (irb):2:in `_racc_yyparse_c'
from parser.y:375:in `scan'
from parser.y:375:in `parse_in'
from racc/parser.rb:152:in `_racc_yyparse_c'
from racc/parser.rb:152:in `__send__'
from racc/parser.rb:152:in `yyparse'
from parser.y:366:in `parse'
from parser.y:344:in `parse'
from /Library/Ruby/Gems/1.8/gems/tmail-1.2.3.1/lib/tmail/address.rb:84:in
`parse'
from (irb):2
>> TMail::Address.parse('[EMAIL PROTECTED]@')
TMail::SyntaxError: parse error on token "@"
from parser.y:379:in `on_error'
from (irb):3:in `_racc_yyparse_c'
from parser.y:375:in `scan'
from parser.y:375:in `parse_in'
from racc/parser.rb:152:in `_racc_yyparse_c'
from racc/parser.rb:152:in `__send__'
from racc/parser.rb:152:in `yyparse'
from parser.y:366:in `parse'
from parser.y:344:in `parse'
from /Library/Ruby/Gems/1.8/gems/tmail-1.2.3.1/lib/tmail/address.rb:84:in
`parse'
from (irb):3
>> TMail::Address.parse('[EMAIL PROTECTED]')
=> #<TMail::Address [EMAIL PROTECTED]>


-- 
http://lindsaar.net/
Rails, RSpec and Life blog....

--~--~---------~--~----~------------~-------~--~----~
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@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to