company_number 0.1.2 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.codeclimate.yml +4 -0
- data/.github/workflows/ci.yml +76 -0
- data/.rubocop.yml +12 -13
- data/.simplecov +6 -0
- data/CHANGELOG.md +13 -0
- data/CODE_OF_CONDUCT.md +2 -2
- data/Gemfile +3 -1
- data/README.md +30 -26
- data/Rakefile +5 -5
- data/bin/setup +1 -1
- data/company_number.gemspec +8 -8
- data/config/dictionary.json +245 -0
- data/lib/company_number/dictionary.rb +2 -2
- data/lib/company_number/validation.rb +2 -1
- data/lib/company_number/version.rb +1 -1
- data/lib/company_number.rb +4 -4
- data/rubocop/rubocop.html +433 -0
- metadata +24 -35
- data/.github/workflows/build.yml +0 -93
- data/config/dictionary.yml +0 -214
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5c42bc8c9b12a33cd82492b9c9390a14a69be90333d9b37e39c39bbe68fb1bf2
|
4
|
+
data.tar.gz: f3b71fa4c422c0babd6d153dc2dd81816f11cd5c58fe8d7e9d0e3427c90375d6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f9cf18f66d4de4f9420f8fe9af73167084f803f53db94c68b5748089e00ac8debbf0fb1649577750e1db3fcf3971f9a54b872f41f220272201bfe10bad4f2857
|
7
|
+
data.tar.gz: 857392a5437580f68e7101a00256dc4935e2048d2b149b43c5a23001a1efed307086437a12d32d9df3bd8610ec0286d8a2d52b620e2003cf3f439716b4525fd0
|
data/.codeclimate.yml
ADDED
@@ -0,0 +1,76 @@
|
|
1
|
+
name: "CI"
|
2
|
+
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
branches:
|
6
|
+
- "*"
|
7
|
+
pull_request:
|
8
|
+
branches:
|
9
|
+
- "*"
|
10
|
+
|
11
|
+
jobs:
|
12
|
+
lint:
|
13
|
+
name: "RuboCop"
|
14
|
+
timeout-minutes: 5
|
15
|
+
runs-on: "ubuntu-latest"
|
16
|
+
steps:
|
17
|
+
- uses: "actions/checkout@v3"
|
18
|
+
|
19
|
+
- name: "Set up Ruby"
|
20
|
+
uses: "ruby/setup-ruby@v1"
|
21
|
+
with:
|
22
|
+
ruby-version: "3.1"
|
23
|
+
bundler-cache: true
|
24
|
+
|
25
|
+
- name: "Run RuboCop"
|
26
|
+
run: "bundle exec rubocop"
|
27
|
+
|
28
|
+
test:
|
29
|
+
runs-on: "ubuntu-latest"
|
30
|
+
strategy:
|
31
|
+
fail-fast: false
|
32
|
+
matrix:
|
33
|
+
ruby-version:
|
34
|
+
- "2.5"
|
35
|
+
- "2.6"
|
36
|
+
- "2.7"
|
37
|
+
- "3.0"
|
38
|
+
- "3.1"
|
39
|
+
|
40
|
+
steps:
|
41
|
+
- uses: "actions/checkout@v3"
|
42
|
+
|
43
|
+
- name: "Set up Ruby"
|
44
|
+
uses: "ruby/setup-ruby@v1"
|
45
|
+
with:
|
46
|
+
ruby-version: "${{ matrix.ruby-version }}"
|
47
|
+
bundler-cache: true
|
48
|
+
|
49
|
+
- name: "Run specs"
|
50
|
+
run: "bundle exec rspec"
|
51
|
+
|
52
|
+
- name: "Upload artifacts"
|
53
|
+
uses: "actions/upload-artifact@v3"
|
54
|
+
with:
|
55
|
+
name: "coverage-artifacts"
|
56
|
+
path: "${{github.workspace}}/coverage/coverage.json"
|
57
|
+
retention-days: 1
|
58
|
+
|
59
|
+
coverage:
|
60
|
+
name: "Report coverage to Code Climate"
|
61
|
+
runs-on: "ubuntu-20.04"
|
62
|
+
needs: "test"
|
63
|
+
if: "success() && github.ref == 'refs/heads/master'"
|
64
|
+
env:
|
65
|
+
CC_TEST_REPORTER_ID: "${{ secrets.CC_TEST_REPORTER_ID }}"
|
66
|
+
|
67
|
+
steps:
|
68
|
+
- uses: "actions/checkout@v3"
|
69
|
+
|
70
|
+
- name: "Download coverage artifacts from test job"
|
71
|
+
uses: "actions/download-artifact@v3"
|
72
|
+
with:
|
73
|
+
name: "coverage-artifacts"
|
74
|
+
- uses: "paambaati/codeclimate-action@v3.2.0"
|
75
|
+
with:
|
76
|
+
coverageLocations: "coverage.json:simplecov"
|
data/.rubocop.yml
CHANGED
@@ -1,19 +1,19 @@
|
|
1
1
|
AllCops:
|
2
|
-
TargetRubyVersion: 2.
|
2
|
+
TargetRubyVersion: 2.5
|
3
|
+
NewCops: enable
|
4
|
+
SuggestExtensions: false
|
5
|
+
Exclude:
|
6
|
+
- "vendor/**/*"
|
3
7
|
|
4
8
|
Style/FrozenStringLiteralComment:
|
5
9
|
Enabled: false
|
6
10
|
|
7
11
|
Style/StringLiterals:
|
8
|
-
|
12
|
+
EnforcedStyle: double_quotes
|
9
13
|
|
10
14
|
Style/Documentation:
|
11
15
|
Enabled: false
|
12
16
|
|
13
|
-
Metrics/BlockLength:
|
14
|
-
Exclude:
|
15
|
-
- spec/**/*
|
16
|
-
|
17
17
|
Metrics/CyclomaticComplexity:
|
18
18
|
Enabled: true
|
19
19
|
|
@@ -22,17 +22,16 @@ Metrics/MethodLength:
|
|
22
22
|
|
23
23
|
Metrics/BlockLength:
|
24
24
|
Exclude:
|
25
|
-
-
|
26
|
-
-
|
25
|
+
- "spec/**/*_spec.rb"
|
26
|
+
- "*.gemspec"
|
27
27
|
|
28
28
|
Layout/LineLength:
|
29
|
-
Max: 80
|
30
29
|
Exclude:
|
31
|
-
-
|
32
|
-
-
|
30
|
+
- "spec/**/*_spec.rb"
|
31
|
+
- "*.gemspec"
|
33
32
|
|
34
33
|
Naming/MemoizedInstanceVariableName:
|
35
|
-
|
34
|
+
EnforcedStyleForLeadingUnderscores: optional
|
36
35
|
|
37
|
-
Gemspec/
|
36
|
+
Gemspec/RequireMFA:
|
38
37
|
Enabled: false
|
data/.simplecov
ADDED
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,18 @@
|
|
1
1
|
## Changelog
|
2
2
|
|
3
|
+
### 0.1.4 - 2022-12-11
|
4
|
+
* Enhancements:
|
5
|
+
* Change dictionary to JSON - 2ced0f8
|
6
|
+
* Aggregating Failures - 54c5655
|
7
|
+
|
8
|
+
* Deprecations:
|
9
|
+
* Change `variations` class from *String* to *Array* - 0eb4074
|
10
|
+
|
11
|
+
### 0.1.3 - 2022-11-04
|
12
|
+
* Enhancements:
|
13
|
+
* Update CI - f67a9e3
|
14
|
+
* Update RuboCop configuration - 3af3dc7
|
15
|
+
|
3
16
|
### 0.1.2 - 2022-04-21
|
4
17
|
* Features:
|
5
18
|
* Add custom configurations - aae0d51
|
data/CODE_OF_CONDUCT.md
CHANGED
@@ -22,7 +22,7 @@ Examples of unacceptable behavior include:
|
|
22
22
|
advances of any kind
|
23
23
|
* Trolling, insulting or derogatory comments, and personal or political attacks
|
24
24
|
* Public or private harassment
|
25
|
-
* Publishing others
|
25
|
+
* Publishing others" private information, such as a physical or email
|
26
26
|
address, without their explicit permission
|
27
27
|
* Other conduct which could reasonably be considered inappropriate in a
|
28
28
|
professional setting
|
@@ -76,7 +76,7 @@ Community leaders will follow these Community Impact Guidelines in determining t
|
|
76
76
|
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0,
|
77
77
|
available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
|
78
78
|
|
79
|
-
Community Impact Guidelines were inspired by [Mozilla
|
79
|
+
Community Impact Guidelines were inspired by [Mozilla"s code of conduct enforcement ladder](https://github.com/mozilla/diversity).
|
80
80
|
|
81
81
|
[homepage]: https://www.contributor-covenant.org
|
82
82
|
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,15 +1,19 @@
|
|
1
1
|
# CompanyNumber
|
2
2
|
|
3
|
-
[![
|
3
|
+
[![Gem Version](https://badge.fury.io/rb/company_number.svg)](https://badge.fury.io/rb/company_number)
|
4
|
+
[![Build Status](https://github.com/VictorAuthiat/company_number/actions/workflows/ci.yml/badge.svg)](https://github.com/VictorAuthiat/company_number/actions/workflows/ci.yml)
|
5
|
+
[![Code Climate](https://codeclimate.com/github/VictorAuthiat/company_number/badges/gpa.svg)](https://codeclimate.com/github/VictorAuthiat/company_number)
|
6
|
+
[![Test Coverage](https://codeclimate.com/github/VictorAuthiat/company_number/badges/coverage.svg)](https://codeclimate.com/github/VictorAuthiat/company_number/coverage)
|
7
|
+
[![Issue Count](https://codeclimate.com/github/VictorAuthiat/company_number/badges/issue_count.svg)](https://codeclimate.com/github/VictorAuthiat/company_number)
|
4
8
|
|
5
9
|
CompanyNumber is a gem allowing you to validate company number based on a country code
|
6
10
|
|
7
11
|
## Installation
|
8
12
|
|
9
|
-
Add this line to your application
|
13
|
+
Add this line to your application"s Gemfile:
|
10
14
|
|
11
15
|
```ruby
|
12
|
-
gem
|
16
|
+
gem "company_number"
|
13
17
|
```
|
14
18
|
|
15
19
|
And then execute:
|
@@ -25,7 +29,7 @@ Or install it yourself as:
|
|
25
29
|
You can obtain a `CompanyNumber::Number` object calling `parse` method:
|
26
30
|
|
27
31
|
```ruby
|
28
|
-
company_number = CompanyNumber.parse(
|
32
|
+
company_number = CompanyNumber.parse("123456789", :fr)
|
29
33
|
|
30
34
|
# => #<CompanyNumber::Number:0x00007fc015d04e18 @company_number="123456789", @country_code=:fr, @metadata={:country=>"France", :name=>"Numéro SIREN ou SIRET", :regexp=>"^(\\d{9}|\\d{14})$", :pattern=>"9 numbers (XXXXXXXXX) or 14 numbers (XXXXXXXXXXXXXX)"}>
|
31
35
|
```
|
@@ -69,14 +73,14 @@ company_number.to_h
|
|
69
73
|
You can compare 2 instances of `CompanyNumber::Number` with `==` method
|
70
74
|
|
71
75
|
```ruby
|
72
|
-
CompanyNumber.parse(
|
76
|
+
CompanyNumber.parse("123") == CompanyNumber.parse("123")
|
73
77
|
# => true
|
74
78
|
```
|
75
79
|
|
76
80
|
Finally you can get the whole dictionary
|
77
81
|
```ruby
|
78
82
|
CompanyNumber.dictionary
|
79
|
-
# => {:at=>{:country=>"Austria", :name=>"Firmenbuchnummer", :regexp=>"^([a-zA-Z]{2}\\d{1,6}|\\d{1,6})[A-Z]$", :pattern=>"2 letters + 6 numbers + 1 letter (LLXXXXXXL)", :variations=>"1-6 numbers + 1 letter (XXXXXXL)"}, ...}
|
83
|
+
# => {:at=>{:country=>"Austria", :name=>"Firmenbuchnummer", :regexp=>"^([a-zA-Z]{2}\\d{1,6}|\\d{1,6})[A-Z]$", :pattern=>"2 letters + 6 numbers + 1 letter (LLXXXXXXL)", :variations=>["1-6 numbers + 1 letter (XXXXXXL)"]}, ...}
|
80
84
|
```
|
81
85
|
|
82
86
|
## Configuration
|
@@ -84,23 +88,23 @@ You can configure your own dictionary using **custom_dictionary**.
|
|
84
88
|
It should be a hash with the country codes as keys and the associated metadata as values.
|
85
89
|
|
86
90
|
Available metadata keys:
|
87
|
-
- country
|
88
|
-
- name
|
89
|
-
- regexp
|
90
|
-
- pattern
|
91
|
-
- variations
|
91
|
+
- country - *String*
|
92
|
+
- name - *String*
|
93
|
+
- regexp - *String*
|
94
|
+
- pattern - *String*
|
95
|
+
- variations - *Array*
|
92
96
|
|
93
97
|
**Example:**
|
94
98
|
```ruby
|
95
|
-
CompanyNumber.parse(
|
96
|
-
CompanyNumber.parse(
|
99
|
+
CompanyNumber.parse("123456789", :fr).valid? # => true
|
100
|
+
CompanyNumber.parse("12345678901234", :fr).valid? # => true
|
97
101
|
|
98
102
|
CompanyNumber.configure do |config|
|
99
|
-
config.custom_dictionary = { fr: { regexp:
|
103
|
+
config.custom_dictionary = { fr: { regexp: "^\d{14}$" } }
|
100
104
|
end
|
101
105
|
|
102
|
-
CompanyNumber.parse(
|
103
|
-
CompanyNumber.parse(
|
106
|
+
CompanyNumber.parse("123456789", :fr).valid? # => false
|
107
|
+
CompanyNumber.parse("12345678901234", :fr).valid? # => true
|
104
108
|
```
|
105
109
|
|
106
110
|
**strict_validation:**
|
@@ -108,36 +112,36 @@ CompanyNumber.parse('12345678901234', :fr).valid? # => true
|
|
108
112
|
You can also enable strict validation to reject unknow countries:
|
109
113
|
|
110
114
|
```ruby
|
111
|
-
CompanyNumber.parse(
|
112
|
-
CompanyNumber.parse(
|
115
|
+
CompanyNumber.parse("123456789").valid? # => true
|
116
|
+
CompanyNumber.parse("123456789", :tt).valid? # => true
|
113
117
|
|
114
118
|
CompanyNumber.configure do |config|
|
115
119
|
config.strict_validation = true
|
116
120
|
end
|
117
121
|
|
118
|
-
CompanyNumber.parse(
|
119
|
-
CompanyNumber.parse(
|
122
|
+
CompanyNumber.parse("123456789").valid? # => false
|
123
|
+
CompanyNumber.parse("123456789", :tt).valid? # => false
|
120
124
|
```
|
121
125
|
|
122
126
|
**excluded_countries:**
|
123
127
|
|
124
|
-
You may want to exclude some countries, this allows you to automatically validate the country
|
128
|
+
You may want to exclude some countries, this allows you to automatically validate the country"s company number when strict validation is not enabled. You can also exclude a country to overwrite all its metadata and define it later in a custom dictionary.
|
125
129
|
|
126
130
|
**Example:**
|
127
131
|
```ruby
|
128
|
-
CompanyNumber.parse(
|
132
|
+
CompanyNumber.parse("123456789", :be).valid? # => false
|
129
133
|
|
130
134
|
CompanyNumber.configure do |config|
|
131
135
|
config.excluded_countries = [:be]
|
132
136
|
end
|
133
137
|
|
134
|
-
CompanyNumber.parse(
|
138
|
+
CompanyNumber.parse("123456789", :be).valid? # => true
|
135
139
|
```
|
136
140
|
|
137
141
|
## Default dictionary:
|
138
142
|
|
139
143
|
- `:at` - **Austria** - Firmenbuchnummer
|
140
|
-
- `:be` - **Belgium** - Numéro d
|
144
|
+
- `:be` - **Belgium** - Numéro d"entreprise Vestigingseenheidsnummer
|
141
145
|
- `:bg` - **Bulgaria** - ЕИК (EIK)/ПИК (PIK) (UIC/PIC)
|
142
146
|
- `:hr` - **Croatia** - Matični broj poslovnog subjekta (MBS)
|
143
147
|
- `:cy` - **Cyprus** - Αριθμός Μητρώου Εταιρίας Şirket kayıt numarası
|
@@ -155,7 +159,7 @@ CompanyNumber.parse('123456789', :be).valid? # => true
|
|
155
159
|
- `:lv` - **Latvia** - Reģistrācijas numurs
|
156
160
|
- `:li` - **Liechtenstein** - UID
|
157
161
|
- `:lt` - **Lithuania** - Juridinio asmens kodas
|
158
|
-
- `:lu` - **Luxembourg** - Numéro d
|
162
|
+
- `:lu` - **Luxembourg** - Numéro d"immatriculation
|
159
163
|
- `:mt` - **Malta** - Registration Number
|
160
164
|
- `:nl` - **Netherlands** - KvK-nummer
|
161
165
|
- `:no` - **Norway** - TIN
|
@@ -184,4 +188,4 @@ The gem is available as open source under the terms of the [MIT License](https:/
|
|
184
188
|
|
185
189
|
## Code of Conduct
|
186
190
|
|
187
|
-
Everyone interacting in the CompanyNumber project
|
191
|
+
Everyone interacting in the CompanyNumber project"s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/victorauthiat/company_number/blob/master/CODE_OF_CONDUCT.md).
|
data/Rakefile
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require "bundler/setup"
|
3
4
|
require "bundler/gem_tasks"
|
4
|
-
require "rspec/core/rake_task"
|
5
|
-
|
6
|
-
RSpec::Core::RakeTask.new(:spec)
|
7
5
|
|
6
|
+
require "rspec/core/rake_task"
|
8
7
|
require "rubocop/rake_task"
|
9
8
|
|
10
|
-
|
9
|
+
RSpec::Core::RakeTask.new(:test)
|
10
|
+
RuboCop::RakeTask.new(:rubocop)
|
11
11
|
|
12
|
-
task default: %i[
|
12
|
+
task default: %i[rubocop test]
|
data/bin/setup
CHANGED
data/company_number.gemspec
CHANGED
@@ -8,9 +8,10 @@ Gem::Specification.new do |spec|
|
|
8
8
|
spec.authors = ["victorauthiat"]
|
9
9
|
spec.email = ["authiatv@gmail.com"]
|
10
10
|
|
11
|
-
spec.summary =
|
12
|
-
spec.homepage =
|
13
|
-
spec.license =
|
11
|
+
spec.summary = "Validate a company number according to a country code"
|
12
|
+
spec.homepage = "https://github.com/victorauthiat/company_number"
|
13
|
+
spec.license = "MIT"
|
14
|
+
spec.required_ruby_version = ">= 2.5"
|
14
15
|
|
15
16
|
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
16
17
|
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{\A(?:test|spec|features)/}) }
|
@@ -19,9 +20,8 @@ Gem::Specification.new do |spec|
|
|
19
20
|
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
|
20
21
|
spec.require_paths = ["lib"]
|
21
22
|
|
22
|
-
spec.add_development_dependency
|
23
|
-
spec.add_development_dependency
|
24
|
-
spec.add_development_dependency
|
25
|
-
spec.add_development_dependency
|
26
|
-
spec.add_development_dependency 'simplecov', '~> 0.21.2'
|
23
|
+
spec.add_development_dependency "bundler"
|
24
|
+
spec.add_development_dependency "rake"
|
25
|
+
spec.add_development_dependency "rspec"
|
26
|
+
spec.add_development_dependency "simplecov"
|
27
27
|
end
|
@@ -0,0 +1,245 @@
|
|
1
|
+
{
|
2
|
+
"at": {
|
3
|
+
"country": "Austria",
|
4
|
+
"name": "Firmenbuchnummer",
|
5
|
+
"regexp": "^([a-zA-Z]{2}\\d{1,6}|\\d{1,6})[A-Z]$",
|
6
|
+
"pattern": "2 letters + 6 numbers + 1 letter (LLXXXXXXL)",
|
7
|
+
"variations": [
|
8
|
+
"1-6 numbers + 1 letter (XXXXXXL)"
|
9
|
+
]
|
10
|
+
},
|
11
|
+
"be": {
|
12
|
+
"country": "Belgium",
|
13
|
+
"name": "Numéro d\"entreprise Vestigingseenheidsnummer",
|
14
|
+
"regexp": "^\\d{10}$",
|
15
|
+
"pattern": "10 numbers (XXXXXXXXXX)"
|
16
|
+
},
|
17
|
+
"bg": {
|
18
|
+
"country": "Bulgaria",
|
19
|
+
"name": "ЕИК (EIK)/ПИК (PIK) (UIC/PIC)",
|
20
|
+
"regexp": "^(\\d{9}|\\d{13})$",
|
21
|
+
"pattern": "9 numbers (XXXXXXXXX)",
|
22
|
+
"variations": [
|
23
|
+
"13 numbers (XXXXXXXXXXXXX)"
|
24
|
+
]
|
25
|
+
},
|
26
|
+
"hr": {
|
27
|
+
"country": "Croatia",
|
28
|
+
"name": "Matični broj poslovnog subjekta (MBS)",
|
29
|
+
"regexp": "^(\\d{8}|\\d{11})$",
|
30
|
+
"pattern": "11 numbers (XXXXXXXXXXX)",
|
31
|
+
"variations": [
|
32
|
+
"8 numbers (XXXXXXXX)"
|
33
|
+
]
|
34
|
+
},
|
35
|
+
"cy": {
|
36
|
+
"country": "Cyprus",
|
37
|
+
"regexp": "^[a-zA-Z]{2}\\d{6}$",
|
38
|
+
"name": "Αριθμός Μητρώου Εταιρίας Şirket kayıt numarası",
|
39
|
+
"pattern": "2 letters + 6 numbers (HEXXXXXX)"
|
40
|
+
},
|
41
|
+
"cz": {
|
42
|
+
"country": "Czech Republic",
|
43
|
+
"name": "Identifikační číslo",
|
44
|
+
"regexp": "^\\d{8}$",
|
45
|
+
"pattern": "8 numbers (XXXXXXXX)"
|
46
|
+
},
|
47
|
+
"dk": {
|
48
|
+
"country": "Denmark",
|
49
|
+
"name": "CVR-nummer",
|
50
|
+
"regexp": "^\\d{8}$",
|
51
|
+
"pattern": "8 numbers (XXXXXXXX)"
|
52
|
+
},
|
53
|
+
"ee": {
|
54
|
+
"country": "Estonia",
|
55
|
+
"name": "Kood",
|
56
|
+
"regexp": "^\\d{8}$",
|
57
|
+
"pattern": "8 numbers (XXXXXXXX)"
|
58
|
+
},
|
59
|
+
"fi": {
|
60
|
+
"country": "Finland",
|
61
|
+
"name": "Y-tunnus FO-nummer",
|
62
|
+
"regexp": "^\\d{8}$",
|
63
|
+
"pattern": "8 numbers (XXXXXXXX)"
|
64
|
+
},
|
65
|
+
"fr": {
|
66
|
+
"country": "France",
|
67
|
+
"name": "Numéro SIREN ou SIRET",
|
68
|
+
"regexp": "^(\\d{9}|\\d{14})$",
|
69
|
+
"pattern": "9 numbers (XXXXXXXXX) or 14 numbers (XXXXXXXXXXXXXX)"
|
70
|
+
},
|
71
|
+
"de": {
|
72
|
+
"country": "Germany",
|
73
|
+
"name": "Nummer der Firma Registernummer",
|
74
|
+
"regexp": "^[a-zA-Z]{1,3}\\d{1,6}[a-zA-Z]{0,3}$",
|
75
|
+
"pattern": "2-3 letters + 6 numbers (LLXXXXXX)",
|
76
|
+
"variations": [
|
77
|
+
"2-3 letters + 1-6 numbers (LLLXXXX)",
|
78
|
+
"2-3 letters + 1-6 numbers + 1 letter (LLLXXXXXXL)",
|
79
|
+
"2-3 letters + 1-6 numbers + 1-2 letter (LLLXXXXXXLL)"
|
80
|
+
]
|
81
|
+
},
|
82
|
+
"gr": {
|
83
|
+
"country": "Greece",
|
84
|
+
"name": "Αριθμό Φορολογικού Μητρώου (Α.Φ.Μ.)",
|
85
|
+
"regexp": "^(\\d{9}|\\d{12})$",
|
86
|
+
"pattern": "9 numbers (XXXXXXXXX)",
|
87
|
+
"variations": [
|
88
|
+
"12 numbers (XXXXXXXXXXXX)"
|
89
|
+
]
|
90
|
+
},
|
91
|
+
"hu": {
|
92
|
+
"country": "Hungary",
|
93
|
+
"name": "Cégjegyzékszáma",
|
94
|
+
"regexp": "^[a-zA-Z]{2}\\d{10}$",
|
95
|
+
"pattern": "2 letters + 10 numbers (LLXXXXXXXXXX)"
|
96
|
+
},
|
97
|
+
"ie": {
|
98
|
+
"country": "Ireland",
|
99
|
+
"name": "Company Number",
|
100
|
+
"regexp": "^(\\d{5}|\\d{6})$",
|
101
|
+
"pattern": "6 numbers (XXXXXX)",
|
102
|
+
"variations": [
|
103
|
+
"5 numbers (XXXXX)"
|
104
|
+
]
|
105
|
+
},
|
106
|
+
"is": {
|
107
|
+
"country": "Island",
|
108
|
+
"name": "TIN",
|
109
|
+
"regexp": "^\\d{10}$",
|
110
|
+
"pattern": "10 numbers (XXXXXXXXXX)"
|
111
|
+
},
|
112
|
+
"it": {
|
113
|
+
"country": "Italy",
|
114
|
+
"name": "Codice fiscale",
|
115
|
+
"regexp": "^[a-zA-Z]{2}\\d{7}|\\d{11}$",
|
116
|
+
"pattern": "11 numbers (XXXXXXXXXXX)",
|
117
|
+
"variations": [
|
118
|
+
"2 letters + 7 numbers (LLXXXXXXX)"
|
119
|
+
]
|
120
|
+
},
|
121
|
+
"lv": {
|
122
|
+
"country": "Latvia",
|
123
|
+
"name": "Reģistrācijas numurs",
|
124
|
+
"regexp": "^\\d{11}$",
|
125
|
+
"pattern": "11 numbers (XXXXXXXXXXX)"
|
126
|
+
},
|
127
|
+
"li": {
|
128
|
+
"country": "Liechtenstein",
|
129
|
+
"name": "UID",
|
130
|
+
"regexp": "^[a-zA-Z]{3}\\d{3}\\s\\d{3}\\s\\d{3}$",
|
131
|
+
"pattern": "3 letters + 9 numbers (LLLXXX XXX XXX)"
|
132
|
+
},
|
133
|
+
"lt": {
|
134
|
+
"country": "Lithuania",
|
135
|
+
"name": "Juridinio asmens kodas",
|
136
|
+
"regexp": "^\\d{9}$",
|
137
|
+
"pattern": "9 numbers (XXXXXXXXX)"
|
138
|
+
},
|
139
|
+
"lu": {
|
140
|
+
"country": "Luxembourg",
|
141
|
+
"name": "Numéro d\"immatriculation",
|
142
|
+
"regexp": "^[a-zA-Z]{1}\\d{6}|[a-jA-J]\\d{3}$",
|
143
|
+
"pattern": "1 letter + 6 numbers (LXXXXXX)",
|
144
|
+
"variations": [
|
145
|
+
"1 letter (from A to J) + 3 numbers (AXXX)"
|
146
|
+
]
|
147
|
+
},
|
148
|
+
"mt": {
|
149
|
+
"country": "Malta",
|
150
|
+
"name": "Registration Number",
|
151
|
+
"regexp": "^[a-zA-Z]{1}\\d{5}$",
|
152
|
+
"pattern": "1 letter + 5 numbers (LXXXXX)"
|
153
|
+
},
|
154
|
+
"nl": {
|
155
|
+
"country": "Netherlands",
|
156
|
+
"name": "KvK-nummer",
|
157
|
+
"regexp": "^\\d{8}$",
|
158
|
+
"pattern": "8 numbers (XXXXXXXX)"
|
159
|
+
},
|
160
|
+
"no": {
|
161
|
+
"country": "Norway",
|
162
|
+
"name": "TIN",
|
163
|
+
"regexp": "^(\\d{9}|\\d{11})$",
|
164
|
+
"pattern": "11 numbers (XXXXXXXXXXX)",
|
165
|
+
"variations": [
|
166
|
+
"9 numbers (XXXXXXXXX)"
|
167
|
+
]
|
168
|
+
},
|
169
|
+
"pl": {
|
170
|
+
"country": "Poland",
|
171
|
+
"name": "Numer w Krajowym Rejestrze Sądowym (numer KRS)",
|
172
|
+
"regexp": "^(\\d{6}|\\d{8})$",
|
173
|
+
"pattern": "8 numbers (XXXXXXXX)",
|
174
|
+
"variations": [
|
175
|
+
"6 numbers (XXXXXX)"
|
176
|
+
]
|
177
|
+
},
|
178
|
+
"pt": {
|
179
|
+
"country": "Portugal",
|
180
|
+
"name": "Número de Identificação Pessoa Coletiva (NIPC)",
|
181
|
+
"regexp": "^(\\d{9}|\\d{3,6})$",
|
182
|
+
"pattern": "9 numbers (XXXXXXXXX)",
|
183
|
+
"variations": [
|
184
|
+
"3-6 numbers (XXXXXX)"
|
185
|
+
]
|
186
|
+
},
|
187
|
+
"ro": {
|
188
|
+
"country": "Romania",
|
189
|
+
"name": "Număr de ordine în Registrul Comerţului",
|
190
|
+
"regexp": "^\\d{3}\\s\\d{2}\\s\\d{3}$",
|
191
|
+
"pattern": "8 numbers (XXX XX XXX)"
|
192
|
+
},
|
193
|
+
"sk": {
|
194
|
+
"country": "Slovakia",
|
195
|
+
"name": "Identifikačného čísla Identification number",
|
196
|
+
"regexp": "^\\d{3}\\s\\d{2}\\s\\d{3}$",
|
197
|
+
"pattern": "8 numbers (XXX XX XXX)"
|
198
|
+
},
|
199
|
+
"si": {
|
200
|
+
"country": "Slovenia",
|
201
|
+
"name": "Matična številka",
|
202
|
+
"regexp": "^\\d{10}|\\d{7,10}$",
|
203
|
+
"pattern": "10 numbers (XXXXXXXXXX)",
|
204
|
+
"variations": [
|
205
|
+
"7 - 10 numbers (XXXXXXXXXX)"
|
206
|
+
]
|
207
|
+
},
|
208
|
+
"es": {
|
209
|
+
"country": "Spain",
|
210
|
+
"name": "Número de identificación fiscal (NIF)",
|
211
|
+
"regexp": "^[a-zA-Z]{1}(\\d{8}|\\d{7}[a-zA-Z]{1})$",
|
212
|
+
"pattern": "1 letter + 8 numbers (LXXXXXXXX)",
|
213
|
+
"variations": [
|
214
|
+
"1 letter + 7 numbers + 1 letter (LXXXXXXXL)"
|
215
|
+
]
|
216
|
+
},
|
217
|
+
"se": {
|
218
|
+
"country": "Sweden",
|
219
|
+
"name": "Registreringsnummer",
|
220
|
+
"regexp": "^\\d{10}$",
|
221
|
+
"pattern": "10 numbers (XXXXXXXXXX)"
|
222
|
+
},
|
223
|
+
"ch": {
|
224
|
+
"country": "Switzerland",
|
225
|
+
"name": "UID",
|
226
|
+
"regexp": "^CHE\\d{9}|\\d{9}$",
|
227
|
+
"pattern": "9 numbers (XXXXXXXXX)",
|
228
|
+
"variations": [
|
229
|
+
"CHE + 9 numbers"
|
230
|
+
]
|
231
|
+
},
|
232
|
+
"gb": {
|
233
|
+
"country": "United Kingdom",
|
234
|
+
"name": "Company Number Registration Number",
|
235
|
+
"regexp": "^\\d{8}|(OC|SC|NI)\\d{6}|R\\d{7}|IP\\d{5}R$",
|
236
|
+
"pattern": "8 numbers (XXXXXXX)",
|
237
|
+
"variations": [
|
238
|
+
"OC + 6 numbers (OCXXXXXX)",
|
239
|
+
"SC + 6 numbers (SCXXXXXX)",
|
240
|
+
"NI + 6 numbers (NIXXXXXX)",
|
241
|
+
"R + 7 numbers (RXXXXXXX)",
|
242
|
+
"IP + 5 numbers + R (IPXXXXXR)"
|
243
|
+
]
|
244
|
+
}
|
245
|
+
}
|
@@ -5,7 +5,7 @@ module CompanyNumber
|
|
5
5
|
attr_reader :country_codes_metadata, :default_hash
|
6
6
|
|
7
7
|
def self.default_dictionary_path
|
8
|
-
File.join(File.dirname(__FILE__),
|
8
|
+
File.join(File.dirname(__FILE__), "../../config/dictionary.json")
|
9
9
|
end
|
10
10
|
|
11
11
|
def initialize(country_codes_metadata = {})
|
@@ -33,7 +33,7 @@ module CompanyNumber
|
|
33
33
|
end
|
34
34
|
|
35
35
|
def load_default_hash
|
36
|
-
|
36
|
+
JSON.parse(
|
37
37
|
File.read(self.class.default_dictionary_path),
|
38
38
|
symbolize_names: true
|
39
39
|
)
|
@@ -43,7 +43,8 @@ module CompanyNumber
|
|
43
43
|
def check_country_code_metadata(metadata)
|
44
44
|
metadata.each do |key, value|
|
45
45
|
check_object_inclusion(key, AVAILABLE_METADATA_KEYS)
|
46
|
-
|
46
|
+
object_class = key == :variations ? Array : String
|
47
|
+
check_object_class(value, [object_class])
|
47
48
|
end
|
48
49
|
end
|
49
50
|
|