Class: Nifval::NifValidator

Inherits:
ActiveModel::EachValidator
  • Object
show all
Defined in:
lib/nifval.rb

Defined Under Namespace

Classes: Document

Instance Method Summary collapse

Instance Method Details

#validate_each(record, attribute, value) ⇒ Object



7
8
9
10
11
# File 'lib/nifval.rb', line 7

def validate_each(record, attribute, value)
  if value.nil? || !Document.new(value).valid?
    record.errors.add(attribute, I18n.t("nifval.wrong"))
  end
end