gpt4 book ai didi

ruby-on-rails - 在哪里可以找到Rails错误消息键的列表?

转载 作者:行者123 更新时间:2023-12-04 10:00:58 24 4
gpt4 key购买 nike

我正在尝试通过修改en.yml来定制我的错误消息。

en:
errors:
messages:
blank: "This is a required field."

现在,每个具有 validates presence: true验证程序的空字段都将显示此新消息。

我想找到要修改的消息类型列表。例如,如何自定义 numericality验证程序消息?还是 greater_than验证器?

有什么建议可以在哪里找到?

最佳答案

这是您可以在en.yml文件中自定义的消息的列表:

validates_acceptance_of
`:accepted` (“must be accepted”)
validates_associated
`:invalid` (“is invalid”)
validates_confirmation_of
`:confirmation` (“doesn’t match confirmation”)
validates_exclusion_of
`:exclusion` (“is reserved”)
validates_format_of
`:invalid` (“is invalid”)
validates_inclusion_of
`:inclusion`(“is not included in the list”)
validates_length_of
`:too_short` (“is too short (minimum is {{count}} characters)”)
`:too_long` (“is too long (maximum is {{count}} characters)”)
validates_length_of (with :is option)
`:wrong_length` (“is the wrong length (should be {{count}} characters)”)
validates_numericality_of
`:not_a_number` (“is not a number”)
validates_numericality_of (with :odd option)
`:odd` (“must be odd”)
validates_numericality_of (with :even option)
`:even` (“must be even”)
validates_numericality_of (with :greater_than option)
`:greater_than` (“must be greater than {{count}}”)
validates_numericality_of (with :greater_than_or_equal_to option)
`:greater_than_or_equal_to` (“must be greater than or equal to {{count}}”)
validates_numericality_of (with :equal_to option)
`:equal_to` (“must be equal to {{count}}”)
validates_numericality_of (with :less_than option)
`:less_than` (“must be less than {{count}}”)
validates_numericality_of (with :less_than_or_equal_to option)
`:less_than_or_equal_to` (“must be less than or equal to {{count}}”)
validates_presence_of
`:blank` (“can’t be blank”)
validates_uniqueness_of
`:taken` (“has already been taken”)

关于ruby-on-rails - 在哪里可以找到Rails错误消息键的列表?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17904608/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com