I don''t think I am using the right terminology! I want to use two different validation rules on one instance variable, that variable being email that comes from a form. I want to verify the presence_of and the format_of. If it is empty then I get both error messages. One from each validation. Is their a rails way to specify to do the first validation and if it passes go to next. It bothers me that two messages appear on the screen i.e. email is required and format of email is invalid. What do you guys suggest?
Rob Park
2005-Mar-11 20:35 UTC
Re: More Then One Validation Rule For One Instance Variable
On Fri, 11 Mar 2005 15:09:41 -0500, John Baku <john-CC0oh5EnFfVBDgjK7y7TUQ@public.gmane.org> wrote:> I want to use two different validation rules on one instance variable, that > variable being email that comes from a form. I want to verify the presence_of > and the format_of. If it is empty then I get both error messages. One from > each validation. Is their a rails way to specify to do the first validation > and if it passes go to next. It bothers me that two messages appear on the > screen i.e. email is required and format of email is invalid. > > What do you guys suggest?I could be wrong on this, but I think having both validations is redundant. Eg, you can just simply use validates_format_of, and if the field is blank, it''ll fail that test. validates_presence_of is completely redundant and won''t catch any errors that validates_format_of won''t already catch. -- One Guy With A Camera http://rbpark.ath.cx
John Baku
2005-Mar-11 21:07 UTC
Re: More Then One Validation Rule For One Instance Variable
I agree with that but in this case it has to do with error messages. I prefer giving specific error messages then combining two error messages into one. Any ideas on how to do what I want to do?> On Fri, 11 Mar 2005 15:09:41 -0500, John Baku <john-CC0oh5EnFfVBDgjK7y7TUQ@public.gmane.org> wrote: > > I want to use two different validation rules on one instance variable, that > > variable being email that comes from a form. I want to verify the > presence_of > > and the format_of. If it is empty then I get both error messages. One > from > > each validation. Is their a rails way to specify to do the first > validation > > and if it passes go to next. It bothers me that two messages appear on the > > screen i.e. email is required and format of email is invalid. > > > > What do you guys suggest? > > I could be wrong on this, but I think having both validations is > redundant. Eg, you can just simply use validates_format_of, and if the > field is blank, it''ll fail that test. validates_presence_of is > completely redundant and won''t catch any errors that > validates_format_of won''t already catch. > > -- > One Guy With A Camera > http://rbpark.ath.cx > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >
Rick Bradley
2005-Mar-11 21:37 UTC
Re: More Then One Validation Rule For One Instance Variable
* John Baku (john-CC0oh5EnFfVBDgjK7y7TUQ@public.gmane.org) [050311 16:09]:> I agree with that but in this case it has to do with error messages. I prefer > giving specific error messages then combining two error messages into one. > > Any ideas on how to do what I want to do?Sure, declare your own validation method which returns different error messages depending upon the nature of the validation failure. Rick -- http://www.rickbradley.com MUPRN: 27 | am familiar random email haiku | with the DOS issues they had | a little while back.