Class: Unidom::ArticleNumber::VehicleIdentificationNumberValidator

Inherits:
ActiveModel::EachValidator
  • Object
show all
Defined in:
app/validators/unidom/article_number/vehicle_identification_number_validator.rb

Overview

Constant Summary collapse

WEIGHTS =
'8765432X098765432'.freeze
TRANSLITERATION =
'0123456789.ABCDEFGH..JKLMN.P.R..STUVWXYZ'.freeze
CHECK_DIGITS =
'0123456789X'.freeze

Instance Method Summary collapse

Instance Method Details

#validate_each(record, attribute, value) ⇒ Object



10
11
12
13
# File 'app/validators/unidom/article_number/vehicle_identification_number_validator.rb', line 10

def validate_each(record, attribute, value)
  value = value.to_s.upcase
  record.errors[attribute] << (options[:message]||'is invalid') unless check_digit(value)==value[8]
end