Class: GS1::Barcode::AttributeValidators::RecordValidator

Inherits:
Object
  • Object
show all
Defined in:
lib/gs1/barcode/attribute_validators/record_validator.rb

Direct Known Subclasses

IgnoringRecordValidator

Instance Method Summary collapse

Instance Method Details

#validate(barcode, attribute_name) ⇒ Object



5
6
7
8
9
10
11
12
13
14
# File 'lib/gs1/barcode/attribute_validators/record_validator.rb', line 5

def validate(barcode, attribute_name)
  barcode.class.records.find { |r| r.underscore_name == attribute_name }.tap do |record|
    if record
      yield record
      next
    end

    on_error(barcode, attribute_name)
  end
end