Class: Valvat::Checksum::FR

Inherits:
Base
  • Object
show all
Defined in:
lib/valvat/checksum/fr.rb

Constant Summary collapse

ALPHABET =

the valid characters for the first two digits (O and I are missing)

'0123456789ABCDEFGHJKLMNPQRSTUVWXYZ'
NUMERIC =
/^\d+$/.freeze

Instance Attribute Summary

Attributes inherited from Base

#vat

Instance Method Summary collapse

Methods inherited from Base

check_digit_length, #initialize

Constructor Details

This class inherits a constructor from Valvat::Checksum::Base

Instance Method Details

#validateObject



10
11
12
13
14
15
16
# File 'lib/valvat/checksum/fr.rb', line 10

def validate
  return super if str_wo_country[0..1] =~ NUMERIC

  check = alt_check_digit

  (str_wo_country[2..].to_i + 1 + (check / 11)) % 11 == check % 11
end