wrong_length: は%{count}文字で入力してください。
existence: は存在しません。
url: はurlの書式で入力してください。
+ natural_number: は1以上の数値で入力してください。
+ not_zero: は0以外の数値で入力してください。
+ resize: はサイズを変更できません。
+ reverse: は反転できません。
+ sync_vh: は縦横比を変更できません。
template:
body: 次の項目を確認してください。
header:
class NaturalNumberValidator < ActiveModel::EachValidator\r
def validate_each(record, attribute, value)\r
- record.errors[attribute] << (options[:message] || "is not natural number") if value.to_i < 1\r
+ record.errors[attribute] << (options[:message] || I18n.t('activerecord.errors.messages.natural_number')) if value.to_i < 1\r
end\r
end\r
-
+\r
class NotZeroValidator < ActiveModel::EachValidator\r
def validate_each(record, attribute, value)\r
- record.errors[attribute] << (options[:message] || "is zero") if value.to_i == 0\r
+ record.errors[attribute] << (options[:message] || I18n.t('activerecord.errors.messages.not_zero')) if value.to_i == 0\r
end\r
end\r
-
+\r
class ResizeValidator < ActiveModel::EachValidator\r
def validate_each(record, attribute, value)\r
if record.picture and record.picture.flag_resize < 0\r
- record.errors[attribute] << (options[:message] || "no resize") unless value == record.picture[attribute]\r
+ record.errors[attribute] << (options[:message] || I18n.t('activerecord.errors.messages.resize')) unless value == record.picture[attribute]\r
end\r
end\r
end\r
class ReverseValidator < ActiveModel::EachValidator\r
def validate_each(record, attribute, value)\r
if record.picture and record.picture.flag_reverse < 0\r
- record.errors[attribute] << (options[:message] || "no reverse") if value < 0\r
+ record.errors[attribute] << (options[:message] || I18n.t('activerecord.errors.messages.reverse')) if value < 0\r
end\r
end\r
end\r
class SyncVhValidator < ActiveModel::EachValidator\r
def validate_each(record, attribute, value)\r
if record.picture and record.picture.flag_sync_vh < 0\r
- record.errors[attribute] << (options[:message] || "sync_vh") unless sync?(record)\r
+ record.errors[attribute] << (options[:message] || I18n.t('activerecord.errors.messages.sync_vh')) unless sync?(record)\r
end\r
end\r
\r