lib/valvat/syntax.rb in valvat-0.1.1 vs lib/valvat/syntax.rb in valvat-0.2.0
- old
+ new
@@ -1,8 +1,8 @@
-require 'valvat/utils'
+require 'valvat'
-module Valvat
+class Valvat
module Syntax
VAT_PATTERNS = {
'AT' => /\AATU[0-9]{8}\Z/, # Austria
'BE' => /\ABE[0-9]{10}\Z/, # Belgium
@@ -32,11 +32,12 @@
'SI' => /\ASI[0-9]{8}\Z/, # Slovenia
'SK' => /\ASK[0-9]{10}\Z/ # Slovakia
}
def self.validate(vat)
- pattern = VAT_PATTERNS[Valvat::Utils.split(vat)[0]]
- !!(pattern && pattern =~ vat)
+ vat = Valvat(vat)
+ pattern = VAT_PATTERNS[vat.iso_country_code]
+ !!(pattern && pattern =~ vat.to_s)
end
end
end
\ No newline at end of file