Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6794511
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T18:13:51+00:00 2026-05-26T18:13:51+00:00

The following validation code in the model: validates :formatted_address, :zip, :city, :state, :country, :presence

  • 0

The following validation code in the model:

validates :formatted_address, :zip, :city, :state, :country, :presence => true, :message => "is incomplete. Please enter full address."

is displayed when either of the fields are empty. Let’s say now :address and country are empty, 2 errors are displayed:

Formatted Address is incomplete. Please enter full address.
Country is incomplete. Please enter full address.

How can I group the error message in the validation to just show one error message if either of the fields validated does not exist?

Address is incomplete. Please enter full address.

Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T18:13:51+00:00Added an answer on May 26, 2026 at 6:13 pm

    You could just write your own validator using the validate macro:

    validate :has_complete_address
    
    #...
    
    private
    def has_complete_address
        # Check that everything is there and
        # call self.errors.add to store an error
        # message if something is wrong.
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following validation in my model ( User ): validates :first_name,:length =>
I have the following code validation php script: if(empty($_POST['captcha_code'])) { $error = 1; $code[3]
I have been following the validation for Entry boxes from here . The code
I have the following code to enable validation work: $(document).ready(function() { $(#eventForm).validate({ rules: {
I have the following code block for validation in PHP and I can't figure
I am using the following code for my form validation. The code is working
i am using a jquery validation in form my code is following Jquery $(document).ready(function
I'm working with the jQuery Validation plugin and I wrote the following code which
I have the following validation in a model: validates_length_of :description, :minimum => 2, :on
In a model say Task , I have following validation validates_presence_of :subject, :project, :user,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.