Sha256: 52c60e771edbdc7fe303cbf26e483824e8770e742979cd2932c8331019d6fd76

Contents?: true

Size: 800 Bytes

Versions: 3

Compression:

Stored size: 800 Bytes

Contents

module ItaxCode
  # Handles the validation logic.
  #
  # @param [Hash] data The user input data
  class Validator
    LENGTH = 16

    def initialize(data = {})
      @encoded = Encoder.new(data).encode
    end

    class << self
      # Checks the tax code standard length against user
      # and business fical code standards.
      #
      # @param [String] code The tax code
      #
      # @return [true, false]
      def standard_length?(code)
        code.length == LENGTH
      end
    end

    # Checks pre computed tax code validity against newly encoded tax code.
    #
    # @param [String] tax_code The pre computed tax code
    #
    # @return [true, false]
    def valid?(tax_code)
      encoded[0..10] == tax_code[0..10]
    end

    private

      attr_accessor :encoded
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
itax_code-0.3.0 lib/itax_code/validator.rb
itax_code-0.2.0 lib/itax_code/validator.rb
itax_code-0.1.4 lib/itax_code/validator.rb