valvat 0.8.1 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (72) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data.tar.gz.sig +0 -0
  4. data/.gitignore +2 -1
  5. data/.travis.yml +30 -16
  6. data/CHANGES.md +45 -2
  7. data/Gemfile +2 -3
  8. data/README.md +96 -46
  9. data/certs/yolk.pem +24 -20
  10. data/gemfiles/activemodel-3-2 +3 -4
  11. data/gemfiles/activemodel-4 +3 -4
  12. data/gemfiles/activemodel-5 +4 -5
  13. data/gemfiles/activemodel-6 +7 -0
  14. data/gemfiles/before-ruby21/activemodel-3-2 +3 -4
  15. data/gemfiles/before-ruby21/activemodel-4 +3 -4
  16. data/gemfiles/before-ruby21/standalone +3 -4
  17. data/gemfiles/standalone +3 -5
  18. data/lib/active_model/validations/valvat_validator.rb +20 -5
  19. data/lib/valvat.rb +3 -1
  20. data/lib/valvat/checksum/gb.rb +30 -13
  21. data/lib/valvat/checksum/ie.rb +1 -1
  22. data/lib/valvat/checksum/nl.rb +5 -0
  23. data/lib/valvat/checksum/si.rb +2 -2
  24. data/lib/valvat/error.rb +28 -0
  25. data/lib/valvat/local.rb +2 -1
  26. data/lib/valvat/locales/en.yml +1 -1
  27. data/lib/valvat/locales/fr.yml +17 -17
  28. data/lib/valvat/locales/pt.yml +28 -28
  29. data/lib/valvat/lookup.rb +11 -43
  30. data/lib/valvat/lookup/fault.rb +30 -0
  31. data/lib/valvat/lookup/request.rb +33 -12
  32. data/lib/valvat/lookup/response.rb +36 -0
  33. data/lib/valvat/utils.rb +11 -3
  34. data/lib/valvat/version.rb +1 -1
  35. data/spec/active_model/validations/valvat_validator_spec.rb +92 -66
  36. data/spec/valvat/checksum/at_spec.rb +2 -2
  37. data/spec/valvat/checksum/be_spec.rb +2 -2
  38. data/spec/valvat/checksum/bg_spec.rb +2 -2
  39. data/spec/valvat/checksum/cy_spec.rb +2 -2
  40. data/spec/valvat/checksum/de_spec.rb +2 -2
  41. data/spec/valvat/checksum/dk_spec.rb +2 -2
  42. data/spec/valvat/checksum/ee_spec.rb +2 -2
  43. data/spec/valvat/checksum/es_spec.rb +2 -2
  44. data/spec/valvat/checksum/fi_spec.rb +2 -2
  45. data/spec/valvat/checksum/fr_spec.rb +2 -2
  46. data/spec/valvat/checksum/gb_spec.rb +5 -3
  47. data/spec/valvat/checksum/gr_spec.rb +2 -2
  48. data/spec/valvat/checksum/hr_spec.rb +2 -2
  49. data/spec/valvat/checksum/hu_spec.rb +2 -2
  50. data/spec/valvat/checksum/ie_spec.rb +8 -2
  51. data/spec/valvat/checksum/it_spec.rb +4 -4
  52. data/spec/valvat/checksum/lt_spec.rb +2 -2
  53. data/spec/valvat/checksum/lu_spec.rb +2 -2
  54. data/spec/valvat/checksum/mt_spec.rb +2 -2
  55. data/spec/valvat/checksum/nl_spec.rb +4 -4
  56. data/spec/valvat/checksum/pl_spec.rb +3 -3
  57. data/spec/valvat/checksum/pt_spec.rb +2 -2
  58. data/spec/valvat/checksum/ro_spec.rb +2 -2
  59. data/spec/valvat/checksum/se_spec.rb +3 -3
  60. data/spec/valvat/checksum/si_spec.rb +7 -7
  61. data/spec/valvat/checksum_spec.rb +2 -2
  62. data/spec/valvat/lockup/fault_spec.rb +32 -0
  63. data/spec/valvat/lockup/request_spec.rb +15 -0
  64. data/spec/valvat/lockup/response_spec.rb +27 -0
  65. data/spec/valvat/lookup_spec.rb +168 -35
  66. data/spec/valvat/syntax_spec.rb +29 -29
  67. data/spec/valvat/utils_spec.rb +28 -8
  68. data/spec/valvat_spec.rb +18 -18
  69. data/valvat.gemspec +1 -0
  70. metadata +52 -25
  71. metadata.gz.sig +0 -0
  72. data/lib/valvat/lookup/request_with_id.rb +0 -31
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 903981843bd7255fc3baa92e31f82d45115a3b736fb1c4777a8009c61b9ddcf6
4
- data.tar.gz: 0ccb923e2374626b86d160ffde0ced09e585f9daa0cb4bd3d5cc1e889cd4ecac
3
+ metadata.gz: 6c35eea0081e4df97219ee215ea3321c8add02bc130c5b28488f1dca676765dc
4
+ data.tar.gz: 4ba7b89f223d26d1ac9d967944d6c2e0dbea74c3c6066f1d69d0e2f42ba204c8
5
5
  SHA512:
6
- metadata.gz: 149b8c92ae2a3b9eaf8bf3df09809598a38f5fc16700eb491b24fac05b5f5e242db470feda944846ea8b129ee7f39c4bdb2b809c6cf02eafeaaf31a6ffc7fb6c
7
- data.tar.gz: cac991af7a40140cd289a6166044258eebd2450333dd3ae3de8dc4565c03f2eeaf662c8d7357f0eb820963f37b88b420c1c5486fe0ff902dea428b1438fe4f37
6
+ metadata.gz: ab9623bd1d680546ca7978751b6536b626d2d5cb9ae35240b5152d4e7c9512e99e025481bf0a844254e6ad14d3f1f320dbf54ab6901387e354b7682c45cb3c3c
7
+ data.tar.gz: 79a69d5d148b86282f609d66bf053a1b14d4bd86621d7277a5f17d1d1df6c6fd5c9731cff4eca8c8bb9dde9f1265eef7ea03c60d2d66876b0f255d97a9596a6b
Binary file
data.tar.gz.sig CHANGED
Binary file
data/.gitignore CHANGED
@@ -2,6 +2,7 @@ pkg/*
2
2
  *.gem
3
3
  .bundle
4
4
  Gemfile.lock
5
+ gemfiles/*.lock
5
6
  tmp
6
7
  .rbenv-*
7
- .ruby-version
8
+ .ruby-version
@@ -1,33 +1,47 @@
1
1
  language: ruby
2
+ cache: bundler
2
3
  rvm:
4
+ - 2.7
3
5
  - 2.6
4
6
  - 2.5
5
7
  - 2.4
6
8
  - 2.3
7
9
  - 2.2
8
10
  - 2.1
11
+ - jruby-head
9
12
  - jruby-19mode
10
13
  gemfile:
14
+ - gemfiles/activemodel-6
11
15
  - gemfiles/activemodel-5
12
16
  - gemfiles/activemodel-4
13
17
  - gemfiles/activemodel-3-2
14
18
  - gemfiles/standalone
15
19
  matrix:
16
20
  exclude:
17
- - rvm: 2.1
18
- gemfile: gemfiles/activemodel-5
19
- - rvm: jruby-19mode
20
- gemfile: gemfiles/activemodel-5
21
+ - rvm: 2.4
22
+ gemfile: gemfiles/activemodel-6
23
+ - rvm: 2.3
24
+ gemfile: gemfiles/activemodel-6
25
+ - rvm: 2.2
26
+ gemfile: gemfiles/activemodel-6
27
+ - rvm: 2.1
28
+ gemfile: gemfiles/activemodel-6
29
+ - rvm: jruby-19mode
30
+ gemfile: gemfiles/activemodel-6
31
+ - rvm: 2.1
32
+ gemfile: gemfiles/activemodel-5
33
+ - rvm: jruby-19mode
34
+ gemfile: gemfiles/activemodel-5
21
35
  include:
22
- - rvm: 2.0
23
- gemfile: gemfiles/before-ruby21/activemodel-4
24
- - rvm: 2.0
25
- gemfile: gemfiles/before-ruby21/activemodel-3-2
26
- - rvm: 2.0
27
- gemfile: gemfiles/before-ruby21/standalone
28
- - rvm: 1.9.3
29
- gemfile: gemfiles/before-ruby21/activemodel-4
30
- - rvm: 1.9.3
31
- gemfile: gemfiles/before-ruby21/activemodel-3-2
32
- - rvm: 1.9.3
33
- gemfile: gemfiles/before-ruby21/standalone
36
+ - rvm: 2.0
37
+ gemfile: gemfiles/before-ruby21/activemodel-4
38
+ - rvm: 2.0
39
+ gemfile: gemfiles/before-ruby21/activemodel-3-2
40
+ - rvm: 2.0
41
+ gemfile: gemfiles/before-ruby21/standalone
42
+ - rvm: 1.9.3
43
+ gemfile: gemfiles/before-ruby21/activemodel-4
44
+ - rvm: 1.9.3
45
+ gemfile: gemfiles/before-ruby21/activemodel-3-2
46
+ - rvm: 1.9.3
47
+ gemfile: gemfiles/before-ruby21/standalone
data/CHANGES.md CHANGED
@@ -1,6 +1,49 @@
1
+
1
2
  ### dev
2
3
 
3
- [full changelog](http://github.com/yolk/valvat/compare/v0.8.1...master)
4
+ [full changelog](http://github.com/yolk/valvat/compare/v1.0.1...master)
5
+
6
+ ### 1.0.1 / 2020-12-06
7
+
8
+ [full changelog](http://github.com/yolk/valvat/compare/v1.0.0...v1.0.1)
9
+
10
+ * Added missing spaces to malformatted portuegese locale file
11
+ * Removed GB from EU_COUNTRIES / EU_MEMBER_STATES but kept support
12
+ * Fixed typo in error message: UNK(N)OWN (by [Igor Gonchar](https://github.com/gigorok))
13
+
14
+ ### 1.0.0 / 2020-11-06
15
+
16
+ [full changelog](http://github.com/yolk/valvat/compare/v0.9.1...v1.0.0)
17
+
18
+ * Refactored lookup to use specific rescue for savons soapfaults
19
+ * Raises vies specific error classes to help debugging temporary and permanent VIES errors
20
+ * Lookup#validate supports :savon option to allow altering the behaviour of the used savon client
21
+ * ActiveModel validator now supports all lookup options.
22
+ * Use https instead of http for accessing vies (by [Crazy Chris](https://github.com/lubekpl))
23
+ * Lookup#validate supports :raise_error option to return nil instead of raising (known) error when connecting to the VIES web service.
24
+ * [BUGFIX] Checksum: Prevent error on some invalid IE vat numbers
25
+ * EN: Capitalized VAT in error messages (and specs) (by [Vitalii Kashoid](https://github.com/Kashoid23))
26
+
27
+ ### 0.9.1 / 2020-03-19
28
+
29
+ [full changelog](http://github.com/yolk/valvat/compare/v0.9.0...v0.9.1)
30
+
31
+ * Follow redirects to fix alteration of VIES-API (by [xxswingxx](https://github.com/xxswingxx))
32
+
33
+ ### 0.9.0 / 2020-02-28
34
+
35
+ [full changelog](http://github.com/yolk/valvat/compare/v0.8.2...v0.9.0)
36
+
37
+ * Validate new dutch 2020 vat identification number (by [yvonnenieuwerth](https://github.com/yvonnenieuwerth))
38
+ * Set the country adjectives to masculine in FR locales (by [bobmaerten](https://github.com/bobmaerten))
39
+ * Fix greek country adjectif in french (by [bobmaerten](https://github.com/bobmaerten))
40
+
41
+ ### 0.8.2 / 2019-11-15
42
+
43
+ [full changelog](http://github.com/yolk/valvat/compare/v0.8.1...v0.8.2)
44
+
45
+ * Fixed checksum computation for Slovenian VAT ID.
46
+ * Updated normalize regexp to clean spaces, punctuation and control chars (by [jarthod](https://github.com/jarthod))
4
47
 
5
48
  ### 0.8.1 / 2019-07-30
6
49
 
@@ -294,4 +337,4 @@
294
337
 
295
338
  [full changelog](http://github.com/yolk/valvat/compare/v0.0.1...v0.0.2)
296
339
 
297
- * Use REST-wrapper for accessing VIES web service; this removes dependency on savon and some lines of code. See http://isvat.appspot.com/
340
+ * Use REST-wrapper for accessing VIES web service; this removes dependency on savon and some lines of code. See http://isvat.appspot.com/
data/Gemfile CHANGED
@@ -1,7 +1,6 @@
1
- source 'http://rubygems.org'
1
+ source 'https://rubygems.org'
2
2
 
3
3
  # Specify your gem's dependencies in valvat.gemspec
4
4
  gemspec
5
5
 
6
- gem 'rake'
7
- gem 'guard-rspec', '~>4.0'
6
+ gem 'guard-rspec', '~>4.0'
data/README.md CHANGED
@@ -5,6 +5,10 @@ valvat
5
5
 
6
6
  Validates european vat numbers. Standalone or as a ActiveModel validator.
7
7
 
8
+ ## A note on Brexit
9
+
10
+ Valvat supports validating VAT-IDs from the UK by syntax & checksum for now. Validation against the VIES web service will probably stop working (and return `false`) in 2021.
11
+
8
12
  ## Features
9
13
 
10
14
  * Simple syntax verification
@@ -14,7 +18,7 @@ Validates european vat numbers. Standalone or as a ActiveModel validator.
14
18
  * I18n locales for language specific error messages in English, German, French, Spanish, Italian, Portuguese, Polish, Swedish, Dutch, Danish, Czech, Slovakian, Hungarian, Bulgarian, Romanian, Latvian, Catalan, Norwegian, and Finnish.
15
19
  * *Experimental* checksum verification
16
20
 
17
- valvat is tested and works with ruby MRI 1.9.3/2.0/2.1/2.2/2.3/2.4/2.5/2.6, jruby (in 1.9 mode) and ActiveModel 3/4/5
21
+ valvat is tested and works with ruby MRI 1.9.3/2.0/2.1/2.2/2.3/2.4/2.5/2.6/2.7, jruby (including 1.9 mode) and ActiveModel 3/4/5/6
18
22
 
19
23
  ## Installation
20
24
 
@@ -22,9 +26,9 @@ Add it to your Gemfile:
22
26
 
23
27
  gem 'valvat'
24
28
 
25
- To save most of the used memory and load only the local verification functionality – and not the remote lookup with VIES – add it like this instead:
29
+ To use less memory (~3.5 mb vs. ~0.5 mb) and load only the local verification functionality – and not the remote lookup with VIES – add it like this instead:
26
30
 
27
- gem 'valvat', :require => 'valvat/local'
31
+ gem 'valvat', require: 'valvat/local'
28
32
 
29
33
  In any case run:
30
34
 
@@ -34,72 +38,114 @@ Or install it yourself as:
34
38
 
35
39
  $ gem install valvat
36
40
 
37
- ## Basic Usage
41
+ ## Validate the syntax of a VAT number
38
42
 
39
43
  To verify the syntax of a vat number:
40
44
 
41
45
  Valvat.new("DE345789003").valid?
42
46
  => true or false
43
47
 
44
- To check if the given vat number exists via the VIES web service:
45
-
46
- Valvat.new("DE345789003").exists?
47
- => true or false or nil
48
+ It is also possible to bypass initializing a Valvat instance and check the syntax of a vat number string directly with:
48
49
 
49
- *IMPORTANT* Keep in mind that the VIES web service might be offline at some time for some countries. If this happens `exists?` or `Valvat::Lookup.validate` will return `nil`.
50
+ Valvat::Syntax.validate("DE345789003")
51
+ => true or false
50
52
 
51
- Visit [http://ec.europa.eu/taxation_customs/vies/viesspec.do](http://ec.europa.eu/taxation_customs/vies/viesspec.do) for more accurate information at what time the service for a specific country will be down.
53
+ ## Validate agains the VIES web service
52
54
 
53
- It is also possible to bypass initializing a Valvat instance and check the syntax of a var number string directly with:
55
+ To check if the given vat number exists via the VIES web service:
54
56
 
55
- Valvat::Syntax.validate("DE345789003")
56
- => true or false
57
+ Valvat.new("DE345789003").exists?
58
+ => true or false or nil
57
59
 
58
60
  Or to lookup a vat number string directly via VIES web service:
59
61
 
60
62
  Valvat::Lookup.validate("DE345789003")
61
63
  => true or false or nil
62
64
 
63
- ## Experimental checksum verification
64
-
65
- valvat allows to check vat numbers from AT, BE, BG, DE, DK, ES, FR, FI, GR, IE, IT, LU, NL, PL, PT, SE and SI against a checksum calculation. All other countries will fall back to a simple syntax check:
66
-
67
- Valvat.new("DE345789003").valid_checksum?
68
- => true or false
69
-
70
- These results are more valuable than a simple syntax check, but keep in mind: they can not replace a lookup via VIES.
71
-
72
- *IMPORTANT* This feature was tested against all vat numbers I could get my hand on, but it is still marked as *experimental* because these calculations are not documented and may return wrong results.
73
-
74
- To bypass initializing a Valvat instance:
65
+ *IMPORTANT* Keep in mind that the VIES web service might be offline at some time for all or some member states. If this happens `exists?` or `Valvat::Lookup.validate` will return `nil`. See *Handling of VIES maintenance errors* for further details.
75
66
 
76
- Valvat::Checksum.validate("DE345789003")
77
- => true or false
67
+ ### Details & request identifier
78
68
 
79
- ## Details & request identifier
69
+ If you need all details and not only if the VAT is valid, pass {detail: true} as second parameter to the lookup call.
80
70
 
81
- If you need all details and not only if the VAT is valid, pass {:detail => true} as second parameter to the lookup call.
82
-
83
- Valvat.new("IE6388047V").exists?(:detail => true)
71
+ Valvat.new("IE6388047V").exists?(detail: true)
84
72
  => {
85
- :country_code=>"IE", :vat_number => "6388047V",
73
+ :country_code=>"IE", :vat_number => "6388047V", :valid => true,
86
74
  :request_date => Date.today, :name=>"GOOGLE IRELAND LIMITED",
87
75
  :address=>"1ST & 2ND FLOOR ,GORDON HOUSE ,BARROW STREET ,DUBLIN 4"
88
76
  } or false or nil
89
77
 
90
- According to EU law, or at least as Austria sees it, it's mandatory to verify the UID number of every new customer, but also to check the UID Number periodicaly. To prove that you have checked the UID number, the VIES Web service can return a requestIdentifier.
78
+ According to EU law, or at least as Austria sees it, it's mandatory to verify the VAT number of every new customer, but also to check the VAT number periodicaly. To prove that you have checked the VAT number, the VIES Web service can return a `request_identifier`.
91
79
 
92
- To receive a requestIdentifier you need to pass your own VAT number in the options hash. In this Example, Google (VAT IE6388047V) is checking the validity of eBays VAT number (LU21416127)
80
+ To receive a `request_identifier` you need to pass your own VAT number in the options hash. In this example, Google (VAT IE6388047V) is checking the validity of eBays VAT number (LU21416127)
93
81
 
94
- Valvat.new("LU21416127").exists?(:requester_vat => "IE6388047V")
82
+ Valvat.new("LU21416127").exists?(requester: "IE6388047V")
95
83
  => {
96
- :country_code=>"LU", :vat_number => "21416127",
84
+ :country_code=>"LU", :vat_number => "21416127", :valid => true,
97
85
  :request_date => Date.today, :name=>"EBAY EUROPE S.A R.L.",
98
86
  :address => "22, BOULEVARD ROYAL\nL-2449 LUXEMBOURG",
99
87
  :company_type => nil, :request_identifier => "some_uniq_string"
100
88
  } or false or nil
101
89
 
102
- ## Usage with ActiveModel / Rails 3
90
+ If the given `requester` is invalid, a `Valvat::InvalidRequester` error is thrown.
91
+
92
+ ### Handling of VIES maintenance errors
93
+
94
+ From time to time the VIES web service for one or all member states is down for maintenance. To handle this kind of temporary errors, `Valvat::Lookup#validate` returns `nil` by default to indicate that there is no way at the moment to say if the given VAT is valid or not. You should revalidate the VAT later. If you prefer an error, use the `raise_error` option:
95
+
96
+ Valvat.new("IE6388047V").exists?(raise_error: true)
97
+
98
+ This raises `Valvat::ServiceUnavailable` or `Valvat::MemberStateUnavailable` instead of returning `nil`.
99
+
100
+ Visit [http://ec.europa.eu/taxation_customs/vies/viesspec.do](http://ec.europa.eu/taxation_customs/vies/viesspec.do) for more accurate information at what time the service for a specific member state will be down.
101
+
102
+ ### Handling of other VIES errors
103
+
104
+ All other errors accuring while validating against the VIES web service are raised and must be handled by you. These include:
105
+
106
+ * `Valvat::InvalidRequester`
107
+ * `Valvat::BlockedError`
108
+ * `Valvat::RateLimitError`
109
+ * `Valvat::Timeout`
110
+ * all IO errors
111
+
112
+ If you want to suppress all known error cases. Pass in the `raise_error` option set to `false`:
113
+
114
+ Valvat.new("IE6388047V").exists?(raise_error: false)
115
+
116
+ This will return `nil` instead of raising a known error.
117
+
118
+ ### Set options for the savon client
119
+
120
+ Use the `:savon` key to set options for the used savon SOAP client. For example to log all requests:
121
+
122
+ Valvat.new("IE6388047V").exists?(savon: {log: true})
123
+
124
+ Or to use higher timeouts for the requests:
125
+
126
+ Valvat.new("IE6388047V").exists?(savon: {open_timeout: 10, read_timeout: 10})
127
+
128
+ ### Skip local validation before lookup
129
+
130
+ To prevent unnecessary requests, valvat performs a local syntax check before making the request to the VIES web service. If you want to skip this step (for any reason), set the `:skip_local_validation` option to `true`.
131
+
132
+ ## Experimental checksum verification
133
+
134
+ valvat allows to check vat numbers from AT, BE, BG, DE, DK, ES, FR, FI, GR, IE, IT, LU, NL, PL, PT, SE and SI against a checksum calculation. All other member states will fall back to a basic syntax check:
135
+
136
+ Valvat.new("DE345789003").valid_checksum?
137
+ => true or false
138
+
139
+ These results are more valuable than a simple syntax check, but keep in mind: they can not replace a lookup via VIES.
140
+
141
+ *IMPORTANT* This feature was tested against all vat numbers I could get my hand on, but it is still marked as *experimental* because these calculations are not documented and may return wrong results.
142
+
143
+ To bypass initializing a Valvat instance:
144
+
145
+ Valvat::Checksum.validate("DE345789003")
146
+ => true or false
147
+
148
+ ## Usage with ActiveModel / Rails
103
149
 
104
150
  ### Loading
105
151
 
@@ -114,30 +160,34 @@ after ActiveModel has been loaded.
114
160
  To validate the attribute `vat_number` add this to your model:
115
161
 
116
162
  class MyModel < ActiveRecord::Base
117
- validates :vat_number, :valvat => true
163
+ validates :vat_number, valvat: true
118
164
  end
119
165
 
120
166
  ### Additional lookup validation
121
167
 
122
168
  To additionally perform a lookup via VIES:
123
169
 
124
- validates :vat_number, :valvat => {:lookup => true}
170
+ validates :vat_number, valvat: {lookup: true}
125
171
 
126
172
  By default this will validate to true if the VIES web service is down. To fail in this case simply add the `:fail_if_down` option:
127
173
 
128
- validates :vat_number, :valvat => {:lookup => :fail_if_down}
174
+ validates :vat_number, valvat: {lookup: {fail_if_down: true}}
175
+
176
+ You can pass in any options accepted by `Valvat::Lookup#validate`:
177
+
178
+ validates :vat_number, valvat: {lookup: {raise_error: true, savon: {log: true}}}
129
179
 
130
180
  ### Additional (and experimental) checksum validation
131
181
 
132
182
  To additionally perform a checksum validation:
133
183
 
134
- validates :vat_number, :valvat => {:checksum => true}
184
+ validates :vat_number, valvat: {checksum: true}
135
185
 
136
186
  ### Additional ISO country code validation
137
187
 
138
188
  If you want the vat number’s (ISO) country to match another country attribute, use the _match_country_ option:
139
189
 
140
- validates :vat_number, :valvat => {:match_country => :country}
190
+ validates :vat_number, valvat: {match_country: :country}
141
191
 
142
192
  where it is supposed that your model has a method named _country_ which returns the country ISO code you want to match.
143
193
 
@@ -145,17 +195,17 @@ where it is supposed that your model has a method named _country_ which returns
145
195
 
146
196
  By default blank vat numbers validate to false. To change this add the `:allow_blank` option:
147
197
 
148
- validates :vat_number, :valvat => {:allow_blank => true}
198
+ validates :vat_number, valvat: {allow_blank: true}
149
199
 
150
200
  ### Allow vat numbers outside of europe
151
201
 
152
202
  To allow vat numbers from outside of europe, add something like this to your model (country_code should return a upcase ISO country code):
153
203
 
154
204
  class MyModel < ActiveRecord::Base
155
- validates :vat_number, :valvat => true, :if => :eu?
205
+ validates :vat_number, valvat: true, if: :eu?
156
206
 
157
207
  def eu?
158
- Valvat::Utils::EU_COUNTRIES.include?(country_code)
208
+ Valvat::Utils::EU_MEMBER_STATES.include?(country_code)
159
209
  end
160
210
  end
161
211
 
@@ -206,7 +256,7 @@ https://github.com/yolk/valvat/graphs/contributors
206
256
 
207
257
  ## BlaBla
208
258
 
209
- Copyright (c) 2011-2019 Yolk Sebastian Munz & Julia Soergel GbR
259
+ Copyright (c) 2011-2020 Yolk Sebastian Munz & Julia Soergel GbR
210
260
 
211
261
  Beyond that, the implementation is licensed under the MIT License.
212
262
 
@@ -1,21 +1,25 @@
1
1
  -----BEGIN CERTIFICATE-----
2
- MIIDZDCCAkygAwIBAgIBATANBgkqhkiG9w0BAQUFADA8MRIwEAYDVQQDDAlzZWJh
3
- c3RpYW4xEjAQBgoJkiaJk/IsZAEZFgJ5bzESMBAGCgmSJomT8ixkARkWAmxrMB4X
4
- DTE4MTEyMjEyMjEwMFoXDTE5MTEyMjEyMjEwMFowPDESMBAGA1UEAwwJc2ViYXN0
5
- aWFuMRIwEAYKCZImiZPyLGQBGRYCeW8xEjAQBgoJkiaJk/IsZAEZFgJsazCCASIw
6
- DQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAL2dehu5l3s+mT/kF7kaoyux9EmA
7
- RjpKifWtVP4NWieXHDZN2mV5dkUdw5TwKDL0IrKtp58ou0AzbEl8LLB7Osi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