New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix email validation error I18n symbol lookup #2730

Closed
wants to merge 1 commit into
base: master
from

Conversation

Projects
None yet
1 participant
@felixbuenemann
Contributor

felixbuenemann commented Mar 21, 2013

And include %{value} for interpolation in validation messages.

The current code hardcodes the I18n key and improperly assigns the error
which leads to several problems:

  • You cannot override the translation message for models/attributes
  • You cannot pass your own I18n key as a symbol (eg. :invalid_email)
  • You cannot use symbol interpolation

This fixes the above problems and is the proper solution for issue #2346.

This fix also applies to 1-2-stable and 1-3-stable.
For a fix against 1-1-stable see PR #2729.

Fix email validation error I18n symbol lookup
And include %{value} for interpolation in validation messages.

The current code hardcodes the I18n key and improperly assigns the error
which leads to several problems:
* You cannot override the translation message for models/attributes
* You cannot pass your own I18n key as a symbol (eg. :invalid_email)
* You cannot use symbol interpolation

This fixes the above problems and is the proper solution for issue #2346.

This fix also applies to 1-2-stable and 1-3-stable.
For a fix against 1-1-stable see PR #2729.
@felixbuenemann

This comment has been minimized.

Show comment
Hide comment
@felixbuenemann

felixbuenemann Mar 21, 2013

Contributor

Example:

class MyModel
  validates :email, email: { message: :invalid_email }
end
en:
  errors:
    messages:
      invalid_email: "%{value} is not a valid email address"

Without this patch, the validation message would be invalid_email instead of foo is not a valid email address.

Contributor

felixbuenemann commented Mar 21, 2013

Example:

class MyModel
  validates :email, email: { message: :invalid_email }
end
en:
  errors:
    messages:
      invalid_email: "%{value} is not a valid email address"

Without this patch, the validation message would be invalid_email instead of foo is not a valid email address.

@radar radar closed this in 57fc910 Mar 28, 2013

@felixbuenemann

This comment has been minimized.

Show comment
Hide comment
@felixbuenemann

felixbuenemann Mar 28, 2013

Contributor

Thanks, Ryan!

Contributor

felixbuenemann commented Mar 28, 2013

Thanks, Ryan!

radar added a commit that referenced this pull request Apr 3, 2013

Fix email validation error I18n symbol lookup
And include %{value} for interpolation in validation messages.

The current code hardcodes the I18n key and improperly assigns the error
which leads to several problems:
* You cannot override the translation message for models/attributes
* You cannot pass your own I18n key as a symbol (eg. :invalid_email)
* You cannot use symbol interpolation

This fixes the above problems and is the proper solution for issue #2346.

This fix also applies to 1-2-stable and 1-3-stable.
For a fix against 1-1-stable see PR #2729.

Fixes #2730
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment