bootstrap-ruby / bootstrap_form

Official repository of the bootstrap_form gem, a Rails form builder that makes it super easy to create beautiful-looking forms using Bootstrap 5.
MIT License
1.64k stars 352 forks source link

Support "^ validation error text" format #447

Open Zmokizmoghi opened 6 years ago

Zmokizmoghi commented 6 years ago

Hi. Russian is a fairly complex language, and russian rails community adopted a hack to achieve human readable complex validation messages. The thing is to drop attribute name and wrote custom validations text for required attribute with ^ at the beginning, for example:

ru:
  activerecord:
    errors:
      models:
        person:
          attributes:
            password:
              too_long: "^Ваш пароль слишком длинный, максимум: %{count} символов"

Popular gem for handle russian locale also supports it

But this hack lead to wrong help-text form invalid input:

image

Will you accept pull request with fix?

mattbrictson commented 6 years ago

This is completely outside my area of expertise, but it seems reasonable to me. I would accept a PR, as long as this behavior can be opt-in. In other words, normally this behavior is not enabled, but a developer can enable it by doing something like

require "bootstrap_form/russian_ext"

in their app (e.g. in a Rails initializer).