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 5995043
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T23:54:16+00:00 2026-05-22T23:54:16+00:00

I have got a form with a bunch of fields and model validations. How

  • 0

I have got a form with a bunch of fields and model validations.

How can I return all possible validation errors that can be raised?

I need it to write locales for all of them.

I want to get a list like this:

password blank
password too_short
password confirmation
login blank
login invalid
email blank
email too_short
email invalid

etc

  • 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-22T23:54:17+00:00Added an answer on May 22, 2026 at 11:54 pm

    Basically what Pablo says, except that the page on the rails docs doesn’t show how to override the messages for a particular model and field. here’s an example from one of my apps:

    activerecord:
      errors:
        full_messages:
          format: "{{message}}"    
        #define standard error messages, which we can overide on per model/per attribute basis further down
        messages:
          inclusion: "{{attribute}} is not included in the list"
          exclusion: "{{attribute}} is reserved"
          invalid: "{{attribute}} is invalid"
          confirmation: "{{attribute}} doesn't match confirmation"
          accepted: "{{attribute}} must be accepted"
          empty: "{{attribute}} can't be empty"
          blank: "{{attribute}} can't be blank"
          too_long: "{{attribute}} is too long (maximum is {{count}} characters)"
          too_short: "{{attribute}} is too short (minimum is {{count}} characters)"
          wrong_length: "{{attribute}} is the wrong length (should be {{count}} characters)"
          taken: "{{attribute}} has already been taken"
          not_a_number: "{{attribute}} is not a number"
          greater_than: "{{attribute}} must be greater than {{count}}"
          greater_than_or_equal_to: "{{attribute}} must be greater than or equal to {{count}}"
          equal_to: "{{attribute}} must be equal to {{count}}"
          less_than: "{{attribute}} must be less than {{count}}"
          less_than_or_equal_to: "{{attribute}} must be less than or equal to {{count}}"
          odd: "{{attribute}} must be odd"
          even: "{{attribute}} must be even"
          record_invalid: "Validation failed: {{errors}}"    
        models:
          quiz:
            blank: "{{attribute}} can not be blank"
          user_session:
            blank: "{{attribute}} can not be blank"
            attributes:
              login:
                invalid: "Please enter your user name"   
              password:
                invalid: "Please note that passwords are case sensitive"  
    

    I’ve also changed the basic format for error messages, as sometimes i didn’t want the field name shoved at the start of the message. So, i changed

    errors:
      format: "{{attribute}} {{message}}"
    

    to

    errors:
      format: "{{message}}"    
    

    Which is why i then specify {{attribute}} in my subsequent errors, to put it back in in most but not all cases.

    Note also that i’m using the old syntax of {{var}} rather than %{var}. The same principles apply though.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We have got a setup where users can either use a web-based form or
I've got a situation where I have a main form that pops up an
I have a bunch of Seam form pages; each has a command button that
I've got some code that will generically get all Controls in a form and
I have a form with a bunch of checkboxes, and a hidden field that
I have got a url in this form - http:\\/\\/en.wikipedia.org\\/wiki\\/The_Truman_Show . How can I
I got a form that have a nested link. The problem that the link
I've got a form where I have two radio buttons and two interchangeable controls
We have got a custom MembershipProvider in ASP.NET . Now there are 2 possible
I have got some code to load an assembly and get all types, which

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.