Sha256: f4e8036f7e103c02033677387b79bc49e79473bd67c6a1822bef8d0fcf6ec7f0

Contents?: true

Size: 235 Bytes

Versions: 6

Compression:

Stored size: 235 Bytes

Contents

class GtinValidator < ActiveModel::EachValidator
  def validate_each(record, attribute, value)
    return if value.blank?

    gtin = BrDocuments::Gtin.new(value)
    record.errors.add(attribute, :invalid) unless gtin.valid?
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
br_documents-0.2.5 lib/br_documents/gtin_validator.rb
br_documents-0.2.4 lib/br_documents/gtin_validator.rb
br_documents-0.2.3 lib/br_documents/gtin_validator.rb
br_documents-0.2.2 lib/br_documents/gtin_validator.rb
br_documents-0.2.1 lib/br_documents/gtin_validator.rb
br_documents-0.2.0 lib/br_documents/gtin_validator.rb