class ActiveModel::Validations::OnlyNumbersValidator
文字列が数字のみであることをチェックする
Public Instance Methods
validate_each(record, _attribute, value)
click to toggle source
# File lib/moca_rlibs/active_model_validators/only_numbers.rb, line 9 def validate_each(record, _attribute, value) return if value.blank? value = value.presence.to_s return if value.match?(/\A[0-9]*\z/) record.errors.add('contain invalid characters (only numbers)') end