Sha256: d9956fd65785adc65b934b267fd1ae466a29b04641f713882d1d533ffaf01425

Contents?: true

Size: 419 Bytes

Versions: 1

Compression:

Stored size: 419 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) == CheckDigitCalculator.calculate(Parser.body(code))
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
jan-0.0.2 lib/jan/validator.rb