Class: ActiveModel::Validations::AbsenceValidator

Inherits:
EachValidator
  • Object
show all
Defined in:
lib/common_lib/active_model/validations/absence.rb

Instance Method Summary collapse

Instance Method Details

#validate(record) ⇒ Object



14
15
16
17
18
19
20
# File 'lib/common_lib/active_model/validations/absence.rb', line 14

def validate(record)
	[attributes].flatten.each do |attribute|
		value = record.send(:read_attribute_for_validation, attribute)
		#	associated default error message is in config/locales/en.yml
		record.errors.add(attribute, :absent, options) unless value.blank?
	end
end