Class: RussianPhone::PresenceValidator

Inherits:
ActiveModel::Validator
  • Object
show all
Defined in:
lib/russian_phone/presence_validator.rb

Instance Method Summary collapse

Instance Method Details

#validate(record) ⇒ Object



5
6
7
8
9
10
11
# File 'lib/russian_phone/presence_validator.rb', line 5

def validate(record)
  options[:fields].each do |field|
    if record.send(field).phone.blank?
      record.errors.add(field, 'Необходимо заполнить')
    end
  end
end