OSDN Git Service

t#31653:add scenario
[pettanr/pettanr.git] / lib / validators / quotes_even_validator.rb
1 class QuotesEvenValidator < ActiveModel::EachValidator\r
2   def validate_each(record, attribute, value)\r
3     record.errors[attribute] << (options[:message] || I18n.t('activerecord.errors.messages.quotes_even')) if value.to_s.split(/ /).size.odd?\r
4   end\r
5 end\r
6 \r