class ItaxCode::Validator

This class holds the validation logic.

@param [Hash] data The user input data

Constants

LENGTH

Attributes

encoded[RW]

Public Class Methods

new(data = {}) click to toggle source
# File lib/itax_code/validator.rb, line 10
def initialize(data = {})
  @encoded = Encoder.new(data).encode
end
standard_length?(code) click to toggle source

This method checks tax code standard length against user and business fical code standards.

@param [String] code The tax code

@return [true, false]

# File lib/itax_code/validator.rb, line 23
def standard_length?(code)
  code.length == LENGTH
end

Public Instance Methods

valid?(tax_code) click to toggle source

This method check pre calculated tax code validity against newly encoded tax code.

@param [String] tax_code The pre calculated tax code

@return [true, false]

# File lib/itax_code/validator.rb, line 36
def valid?(tax_code)
  encoded[0..10] == tax_code[0..10]
end