Hi to all, i''m using the validate_format_of function... i need to check if an address is inserted in the correct way. I mean that the address must have this sintax: street namestreet square namesquare etc.... I''ve looked some example with email address but i didn''t understand it. Anybody knows how can i do?? thanks in advance -- Posted via http://www.ruby-forum.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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Hi, can you provide an actual example? For example, P.O. Box 222 Santa Monica, CA 99999 1234 W 37th Street Los Angeles, CA 93200 1234 W Jefferson Blvd Apt. 6 Culver City, CA 90232 Now, does the above addresses represent the type of input you''re expecting? If so, then you should have similar column names: address1 address2 location_no (Apt/Suite/...) city state zipcode ( 5 + 4 ) If not, please provide an example of the address that you''re attempting to write a regular expression for. OK? Good luck, -Conrad On 7/23/07, Andrea Campagna <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > > Hi to all, > > i''m using the validate_format_of function... > > i need to check if an address is inserted in the correct way. > I mean that the address must have this sintax: > > street namestreet > square namesquare > etc.... > > I''ve looked some example with email address but i didn''t understand it. > > Anybody knows how can i do?? > > thanks in advance > -- > Posted via http://www.ruby-forum.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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Hi Conrad, some good input could be: via milano piazza duomo :) it''s in the italian way!! only the name without numers or ZIP code thanks -- Posted via http://www.ruby-forum.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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Hi Andrea, are you creating fields for each part of the address? If so, what are those fields and what should go into each? OK, I found an example, Via Francesco Saverio Nitti, 28 00156 Roma Thus, you should be able to use the following for the above: <street> <street2> <postalCode> <city> (<province>) <country> I''m guessing that it would be easiest to input the address as follows using the above as an example: <street> = Via Francesco Saverio <street2> = 28 <postalCode> = 00156 <city> = Roma Now, let''s add some validations within the model: validates_presence_of :street, :postal_code, :city validates_format_of :postal_code. :with => /^[0-9]{5}$/ You should be able to add other validations as needed. Let me know if this is what you were looking to do. -Conrad On 7/23/07, Andrea Campagna <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > > Hi Conrad, > > some good input could be: > > via milano > > piazza duomo > > :) it''s in the italian way!! > > only the name without numers or ZIP code > > > thanks > -- > Posted via http://www.ruby-forum.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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
> validates_presence_of :street, :postal_code, :city > validates_format_of :postal_code. :with => /^[0-9]{5}$/ > > You should be able to add other validations as needed. Let me know if > this > is what you were looking to do.Hi again Conrad, for the postal code is great, but i want the same thing with the <street> field. I mean that i want to check if the user insert the value in the correct way without any kind of error. I''ll give u some example to explain it better.... ViaFrancesco Saverio can''t be good because there isn''t the space Vai Francesco Saverio has a digit error "vai" and not "via" thanks -- Posted via http://www.ruby-forum.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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Hi Andrea, I see what you''re talking about now. Is there a database that contains all the valid street names? If this is the case, then one could do a live search for the street field to set it or you can write a validate method that checks the street name against the database. If not, then you''ll have to implement a validate method to verify that the street name is correct based on the rules for Italy street names. Lastly, you might write the validate method verify that the entire address is correct. This would be equivalent to an address verification service for Italy. Guess what? Here''s a web service that verifies an address: http://www.strikeiron.com/sample/GlobalAddress_v4_0/GlobalAddress.aspx Also, it very very easy to use a web service from Rails. If you need information on this, please let me know and I will be glad to help. -Conrad On 7/23/07, Andrea Campagna <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > > > > validates_presence_of :street, :postal_code, :city > > validates_format_of :postal_code. :with => /^[0-9]{5}$/ > > > > You should be able to add other validations as needed. Let me know if > > this > > is what you were looking to do. > > Hi again Conrad, > > for the postal code is great, but i want the same thing with the > <street> field. > I mean that i want to check if the user insert the value in the correct > way without any kind of error. > I''ll give u some example to explain it better.... > > ViaFrancesco Saverio can''t be good because there isn''t the space > > Vai Francesco Saverio has a digit error "vai" and not "via" > > thanks > -- > Posted via http://www.ruby-forum.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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---