Sha256: 741d783e025f3c6ee6128da555b601294fc956157f513b136f0e0c99fd8be156
Contents?: true
Size: 429 Bytes
Versions: 1
Compression:
Stored size: 429 Bytes
Contents
require "jan/parser" require "jan/check_digit_calculator" class Jan module Validator module_function def validate(code) validate_size(code.to_s) && validate_check_digit(code.to_s) end def validate_size(code) [8,13].include?(code.to_s.size) end def validate_check_digit(code) Parser.check_digit(code.to_s) == CheckDigitCalculator.calculate(Parser.body(code.to_s)) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
jan-0.0.3 | lib/jan/validator.rb |