license_plate_validator 2.0.0 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4b14548fad67c137489b550601ec07d6c2bdbffd370041f110dedef142be237c
4
- data.tar.gz: c722040730ca5c1f7e6343a29c08b5f3b5b4962f0154d7bf69470f00f4cb47b3
3
+ metadata.gz: b25c26a8c7f270a159b1491355db4c6a88e0014e0d875281b6353067a0f547cd
4
+ data.tar.gz: cc30d482e59abd743f3a1b8a9a292eb2744098ca56ef9f40f9096229e7e10869
5
5
  SHA512:
6
- metadata.gz: 8b9aaeb5f62a2424afc70df1d44cda8ca1c4546c54d2a3f9e3ced7680e1bb022ce4dbc3479a3859fb28bb61c51a55832e458bfe9019211fc81545d171c04a3d2
7
- data.tar.gz: 01f958e7128b87caef078f52df6fba5c168ed35654dcc40715d554daa059514cbd4fca157b69b3426607e9e22c60d50935fdaa1d543a6d3f0d07e45a4bf5748d
6
+ metadata.gz: 4ad48c6eea20792199e35244cbbed9d60bf1fd229cc360f1b8b264cd67d6d0b8fba0fe35ffbb47f740e127b309cbfc0d2a8a015138e4a3d9a4e4244af26f409a
7
+ data.tar.gz: ccfb742ef1b64edf444f4ea3fd4ab43e79ef1969bcca8d0847a4c64cc4d276699c906b98c648cb55e03436ad39611e11cd10c98c58ac8b3db01d9bdeadbf53d3
@@ -22,6 +22,10 @@ jobs:
22
22
  - gemfiles/Gemfile.rails7.0
23
23
  - gemfiles/Gemfile.rails7.1
24
24
  - gemfiles/Gemfile.rails7.2
25
+ - gemfiles/Gemfile.rails8.0
26
+ exclude:
27
+ - ruby-version: 3.1
28
+ gemfile: gemfiles/Gemfile.rails8.0
25
29
 
26
30
  steps:
27
31
  - uses: actions/checkout@v4
data/CHANGELOG CHANGED
@@ -1,5 +1,14 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## 2.1.0 - 2025-04-14
4
+
5
+ - Add Polish ActiveSupport translations - @ariejan
6
+ - Add validations for Polish license plates. - @ariejan
7
+
8
+ ## 2.0.1 - 2025-01-01
9
+
10
+ - Add support for German E-license plates - @Lisztos
11
+
3
12
  ## 2.0.0 - 2024-09-24
4
13
 
5
14
  - Update dependencies; this may break older Ruby (< 3.1) and Rails (< 7.x) integrations.
data/README.md CHANGED
@@ -3,7 +3,7 @@
3
3
  [![Gem Version](https://badge.fury.io/rb/license_plate_validator.png)](http://badge.fury.io/rb/license_plate_validator)
4
4
  [![Ruby CI](https://github.com/ariejan/license_plate_validator/actions/workflows/test.yml/badge.svg)](https://github.com/ariejan/license_plate_validator/actions)
5
5
 
6
- This gem allows you to easily valdiate license plate fields to be valid
6
+ This gem allows you to easily validate license plate fields to be valid
7
7
  license plates.
8
8
 
9
9
  We're planning on supporting multiple countries, but at this time we can
@@ -11,12 +11,33 @@ only validate Dutch and German license plates.
11
11
 
12
12
  ## Features
13
13
 
14
- Validates Dutch license plates ("kentekens"), includes all ten common Dutch license
15
- plate types.
14
+ Validates license plates for the following countries:
15
+
16
+ ### Netherlands (NL)
17
+ - Supports all standard Dutch license plate formats (e.g., `XX-99-XX`, `99-XX-99`, `XX-99-99`, etc.)
18
+ - Formats with letters, numbers, and combinations thereof
19
+ - Example: `60-NFH-1`
16
20
 
17
21
  Special license plates (like those for the Royal family) are not supported.
18
22
 
19
- Also supports most german license plates, including most diplomatic formats.
23
+ ### Germany (DE)
24
+ - Supports standard German license plate formats
25
+ - Area distinguisher followed by 1-2 characters and 1-4 numbers
26
+ - Diplomatic license plates
27
+ - Testing vehicle plates
28
+ - Example: `K-AB-123`, `GL-A-123H`
29
+
30
+ ### Poland (PL)
31
+ - Standard car plates with 2-letter and 3-letter powiat codes (e.g., `WA 12345`, `GDA J234`)
32
+ - Motorcycle and moped plates
33
+ - Reduced size plates for imported vehicles
34
+ - Classic car plates (yellow background)
35
+ - Temporary and export plates
36
+ - Electric vehicle plates
37
+ - Testing vehicle plates
38
+ - Custom plates
39
+ - Professional plates
40
+ - Example: `WA 1234J`, `W 123`
20
41
 
21
42
  ## Installation
22
43
 
@@ -26,11 +47,11 @@ Add this line to your application's Gemfile:
26
47
 
27
48
  And then execute:
28
49
 
29
- $ bundle
50
+ bundle
30
51
 
31
52
  Or install it yourself as:
32
53
 
33
- $ gem install license_plate_validator
54
+ gem install license_plate_validator
34
55
 
35
56
  ## Usage
36
57
 
@@ -42,7 +63,7 @@ Or install it yourself as:
42
63
 
43
64
  ### Ruby on Rails support
44
65
 
45
- You can use LicensePlateValidator with any ActiveModel class, including
66
+ You can use LicensePlateValidator with any ActiveModel class, including
46
67
  ActiveRecord models:
47
68
 
48
69
  class Vehicle < ActiveRecord::Base
@@ -62,13 +83,13 @@ The `Proc` must return either `nil` (accept all the things) or a valid country c
62
83
 
63
84
  ### Edge cases
64
85
 
65
- * When no country is selected (or set to `nil`), all plates are considered valid.
66
- * When an unknown country is selected, all plates are considered valid (e.g. we assume there are no validation rules for that country)
86
+ - When no country is selected (or set to `nil`), all plates are considered valid.
87
+ - When an unknown country is selected, all plates are considered valid (e.g. we assume there are no validation rules for that country)
67
88
 
68
89
  ### Supported countries
69
90
 
70
- * `:nl` Netherlands; all common "sidecode" number formats.
71
- * `:de` Germany; all regular forms as well as the common diplomatic variants
91
+ - `:nl` Netherlands; all common "sidecode" number formats.
92
+ - `:de` Germany; all regular forms as well as the common diplomatic variants
72
93
 
73
94
  ## I18n
74
95
 
@@ -81,10 +102,10 @@ for details.
81
102
 
82
103
  I'd like to add the following feature (in no specific order), maybe you can help?
83
104
 
84
- * Validate uncommon license plates as well (like CD-dd-dd and AA-dd)
85
- * Check if characters used are actually allowed.
86
- * Output properly formatted license plate numbers
87
- * Add support for other countries where possible. Germany, Belgium, France and Poland are high on the list.
105
+ - Validate uncommon license plates as well (like CD-dd-dd and AA-dd)
106
+ - Check if characters used are actually allowed.
107
+ - Output properly formatted license plate numbers
108
+ - Add support for other countries where possible. Germany, Belgium, France and Poland are high on the list.
88
109
 
89
110
  If you're unsure what to contribute, contact me. :-)
90
111
 
@@ -101,9 +122,9 @@ specs.
101
122
 
102
123
  ## Contributor
103
124
 
104
- * Pascal Widdershoven - for the original regexes for Dutch license plate numbers.
105
- * Edward Poot - for adding new RDW approved license plate schemes
106
- * Marcus Ilgner, evopark - for german license plates
125
+ - Pascal Widdershoven - for the original regexes for Dutch license plate numbers.
126
+ - Edward Poot - for adding new RDW approved license plate schemes
127
+ - Marcus Ilgner, evopark - for german license plates
107
128
 
108
129
  ## License
109
130
 
@@ -3,3 +3,6 @@ source "https://rubygems.org"
3
3
  gem "activemodel", "~> 7.0.0"
4
4
  gem "rspec", "~> 3.13.0"
5
5
  gem "rake"
6
+
7
+ # Pin concurrent-ruby, because >= 1.3.5 is not compatible with ActiveModel 7
8
+ gem 'concurrent-ruby', '1.3.4'
@@ -0,0 +1,5 @@
1
+ source "https://rubygems.org"
2
+
3
+ gem "activemodel", "~> 8.0.0"
4
+ gem "rspec", "~> 3.13.0"
5
+ gem "rake"
@@ -0,0 +1,4 @@
1
+ pl:
2
+ errors:
3
+ messages:
4
+ invalid_license_plate: nie jest prawidłowym numerem rejestracyjnym
@@ -1,3 +1,3 @@
1
1
  class LicensePlateValidator
2
- VERSION = "2.0.0"
2
+ VERSION = '2.1.0'
3
3
  end
@@ -1,6 +1,66 @@
1
1
  class LicensePlateValidator
2
2
 
3
3
  PATTERNS = {
4
+ # Poland
5
+ pl: [
6
+ # Standard car plates (2-letter powiat code)
7
+ /^([A-Z]{2})\s([0-9]{5})$/, # XY 12345
8
+ /^([A-Z]{2})\s([0-9]{4}[A-HJ-NP-TV-Z])$/, # XY 1234J
9
+ /^([A-Z]{2})\s([0-9]{3}[A-HJ-NP-TV-Z]{2})$/, # XY 123JK
10
+ /^([A-Z]{2})\s([0-9][A-HJ-NP-TV-Z][0-9]{3})$/, # XY 1J345
11
+ /^([A-Z]{2})\s([0-9][A-HJ-NP-TV-Z]{2}[0-9]{2})$/, # XY 1JK45
12
+
13
+ # Standard car plates (3-letter powiat code)
14
+ /^([A-Z]{3})\s([A-HJ-NP-TV-Z][0-9]{3})$/, # XYZ J234
15
+ /^([A-Z]{3})\s([0-9]{2}[A-HJ-NP-TV-Z]{2})$/, # XYZ 12JK
16
+ /^([A-Z]{3})\s([0-9][A-HJ-NP-TV-Z][0-9]{2})$/, # XYZ 1J34
17
+ /^([A-Z]{3})\s([0-9]{2}[A-HJ-NP-TV-Z][0-9])$/, # XYZ 12J4
18
+ /^([A-Z]{3})\s([0-9][A-HJ-NP-TV-Z]{2}[0-9])$/, # XYZ 1JK4
19
+ /^([A-Z]{3})\s([A-HJ-NP-TV-Z]{2}[0-9]{2})$/, # XYZ JK34
20
+ /^([A-Z]{3})\s([0-9]{5})$/, # XYZ 12345
21
+ /^([A-Z]{3})\s([0-9]{4}[A-HJ-NP-TV-Z])$/, # XYZ 1234J
22
+ /^([A-Z]{3})\s([0-9]{3}[A-HJ-NP-TV-Z]{2})$/, # XYZ 123JK
23
+
24
+ # Motorcycle plates (2-letter powiat code)
25
+ /^([A-Z]{2})\s([0-9]{4})$/, # XY 1234
26
+ /^([A-Z]{2})\s([0-9]{3}[A-HJ-NP-TV-Z])$/, # XY 123J
27
+ /^([A-Z]{2})\s([0-9][A-HJ-NP-TV-Z][0-9]{2})$/, # XY 1J34
28
+ /^([A-Z]{2})\s([0-9]{2}[A-HJ-NP-TV-Z][0-9])$/, # XY 12J4
29
+ /^([A-Z]{2})\s([0-9]{2}[A-HJ-NP-TV-Z]{2})$/, # XY 12JK
30
+ /^([A-Z]{2})\s([A-HJ-NP-TV-Z]{2}[0-9]{2})$/, # XY JK12
31
+
32
+ # Reduced size plates
33
+ /^([A-Z])\s([0-9]{3})$/, # X 123
34
+ /^([A-Z])\s([0-9]{2}[A-HJ-NP-TV-Z])$/, # X 12J
35
+ /^([A-Z])\s([0-9][A-HJ-NP-TV-Z][0-9])$/, # X 1J2
36
+ /^([A-Z])\s([A-HJ-NP-TV-Z][0-9]{2})$/, # X J12
37
+ /^([A-Z])\s([0-9][A-HJ-NP-TV-Z]{2})$/, # X 1JK
38
+ /^([A-Z])\s([A-HJ-NP-TV-Z]{2}[0-9])$/, # X JK1
39
+ /^([A-Z])\s([A-HJ-NP-TV-Z][0-9][A-HJ-NP-TV-Z])$/, # X J1K
40
+
41
+ # Classic car plates
42
+ /^([A-Z]{2})\s([0-9]{2}[A-HJ-NP-TV-Z])$/, # XY 12J
43
+ /^([A-Z]{2})\s([0-9]{3})$/, # XY 123
44
+ /^([A-Z]{3})\s([0-9][A-HJ-NP-TV-Z])$/, # XYZ 1J
45
+ /^([A-Z]{3})\s([0-9]{2})$/, # XYZ 12
46
+ /^([A-Z]{3})\s([A-HJ-NP-TV-Z][0-9])$/, # XYZ J1
47
+
48
+ # Temporary and export plates
49
+ /^([A-Z][0-9])\s([0-9]{4})$/, # X1 2345
50
+ /^([A-Z][0-9])\s([0-9]{3}[A-HJ-NP-TV-Z])$/, # X1 234J
51
+
52
+ # Testing vehicle plates
53
+ /^([A-Z][0-9])\s([0-9]{3})\sB$/, # X1 234 B
54
+
55
+ # Custom plates
56
+ # Letters must come before digits (they cannot be intermixed)
57
+ /^([A-Z][0-9])\s([A-Z][A-Z]{2,4})$/, # X1 ABCDE (all letters)
58
+ /^([A-Z][0-9])\s([A-Z][A-Z]{1,3}[0-9]{1,2})$/, # X1 ABC12 (letters followed by up to 2 digits)
59
+
60
+ # Professional plates
61
+ /^([A-Z][0-9]{2})\s([0-9]{2}P[0-9]{2})$/ # X12 34P56
62
+ ],
63
+
4
64
  # Netherlands
5
65
  nl: [
6
66
  /^([a-zA-Z]{2})-?([0-9]{2})-?([0-9]{2})$/,
@@ -27,7 +87,7 @@ class LicensePlateValidator
27
87
  # 2. a 2-3-digit-number (country identifier) followed by 1-3 digits
28
88
  # diplomatic license plates can be followed by a single letter
29
89
  # regular license plates can be followed by an 'H' for oldtimers
30
- /^(A|AA|AB|ABG|ABI|AC|AE|A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- ]*\d{1,4}[HE]?)|(9\d{3})|(\d{2,3}\-\d{1,3})[a-z]?)$/i,
31
91
  # more diplomatic license plates ;)
32
92
  /^0[\- ]\d{1,3}[\- ]\d{1,3}\w?$/i
33
93
  ]
@@ -18,7 +18,7 @@ RSpec.describe LicensePlateValidator do
18
18
  subject { LicensePlateValidator.new("a") }
19
19
 
20
20
  it "returns array of symbols" do
21
- expect(subject.supported_countries).to eql([:nl, :de])
21
+ expect(subject.supported_countries).to eql([:pl, :nl, :de])
22
22
  end
23
23
  end
24
24
 
@@ -112,6 +112,7 @@ RSpec.describe LicensePlateValidator do
112
112
  DE_VALID_SAMPLES = [
113
113
  "K-AB-123",
114
114
  "GL-A-123H",
115
+ "B-AD-4563E",
115
116
  "AC A123",
116
117
  "K-9123",
117
118
  "0-12-123",
@@ -138,4 +139,90 @@ RSpec.describe LicensePlateValidator do
138
139
  end
139
140
  end
140
141
  end
142
+
143
+ context "PL - Poland" do
144
+ PL_VALID_SAMPLES = [
145
+ # Standard car plates
146
+ "WA 12345", # Warsaw
147
+ "WA 1234J", # Warsaw
148
+ "WA 123JK", # Warsaw
149
+ "WA 1J345", # Warsaw
150
+ "WA 1JK45", # Warsaw
151
+ "GDA J234", # Gdansk (3-letter code)
152
+ "GDA 12JK", # Gdansk
153
+ "GDA 1J34", # Gdansk
154
+ "GDA 12J4", # Gdansk
155
+ "GDA 1JK4", # Gdansk
156
+ "GDA JK34", # Gdansk
157
+ "GDA 12345", # Gdansk
158
+ "GDA 1234J", # Gdansk
159
+ "GDA 123JK", # Gdansk
160
+
161
+ # Motorcycle plates
162
+ "WA 1234", # Warsaw
163
+ "WA 123J", # Warsaw
164
+ "WA 1J34", # Warsaw
165
+ "WA 12J4", # Warsaw
166
+ "WA 12JK", # Warsaw
167
+ "WA JK12", # Warsaw
168
+
169
+ # Reduced size plates
170
+ "W 123", # Masovian
171
+ "W 12J", # Masovian
172
+ "W 1J2", # Masovian
173
+ "W J12", # Masovian
174
+ "W 1JK", # Masovian
175
+ "W JK1", # Masovian
176
+ "W J1K", # Masovian
177
+
178
+ # Classic car plates
179
+ "WA 12J", # Warsaw
180
+ "WA 123", # Warsaw
181
+ "GDA 1J", # Gdansk
182
+ "GDA 12", # Gdansk
183
+ "GDA J1", # Gdansk
184
+
185
+ # Temporary and export plates
186
+ "W1 2345", # Masovian
187
+ "W1 234J", # Masovian
188
+
189
+ # Testing vehicle plates
190
+ "W1 234 B", # Masovian
191
+
192
+ # Custom plates
193
+ "W1 ABCDE", # Masovian
194
+ "W1 ABC12", # Masovian
195
+
196
+ # Professional plates
197
+ "W12 34P56" # Masovian
198
+ ]
199
+
200
+ PL_INVALID_SAMPLES = [
201
+ # Invalid formats
202
+ "W 1234567", # Too many digits
203
+ "W ABCDEF", # No digit after voivodeship code
204
+ "WXYZ 123", # Too many letters in area code
205
+ "W-123-ABC", # Incorrect separator
206
+ "123 ABC", # No voivodeship code
207
+ "W1234", # No space
208
+ "W1 ABCDE1", # Digit not at the end in custom plate
209
+ "W1 1ABCD", # Digit at the beginning in custom plate
210
+ "W1 AB1CD", # Intermixed digits and letters in custom plate
211
+ "W12 34X56" # Professional plate with wrong letter (not P)
212
+ ]
213
+
214
+ PL_VALID_SAMPLES.each do |number|
215
+ it "accepts '#{number}'" do
216
+ license = LicensePlateValidator.new(number, country: :pl)
217
+ expect(license).to be_valid
218
+ end
219
+ end
220
+
221
+ PL_INVALID_SAMPLES.each do |number|
222
+ it "does not accept '#{number}'" do
223
+ license = LicensePlateValidator.new(number, country: :pl)
224
+ expect(license).not_to be_valid
225
+ end
226
+ end
227
+ end
141
228
  end
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: license_plate_validator
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ariejan de Vroom
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2024-09-24 00:00:00.000000000 Z
10
+ date: 2025-04-14 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: bundler
@@ -78,7 +77,6 @@ files:
78
77
  - ".github/workflows/test.yml"
79
78
  - ".gitignore"
80
79
  - ".rspec"
81
- - ".travis.yml"
82
80
  - CHANGELOG
83
81
  - Gemfile
84
82
  - LICENSE.txt
@@ -88,12 +86,14 @@ files:
88
86
  - gemfiles/Gemfile.rails7.0
89
87
  - gemfiles/Gemfile.rails7.1
90
88
  - gemfiles/Gemfile.rails7.2
89
+ - gemfiles/Gemfile.rails8.0
91
90
  - gemfiles/Gemfile.ruby
92
91
  - lib/license_plate_validator.rb
93
92
  - lib/license_plate_validator/active_model.rb
94
93
  - lib/license_plate_validator/locales/de.yml
95
94
  - lib/license_plate_validator/locales/en.yml
96
95
  - lib/license_plate_validator/locales/nl.yml
96
+ - lib/license_plate_validator/locales/pl.yml
97
97
  - lib/license_plate_validator/version.rb
98
98
  - license_plate_validator.gemspec
99
99
  - spec/license_plate_validator/active_model_spec.rb
@@ -103,7 +103,6 @@ homepage: https://ariejan.github.io/license_plate_validator
103
103
  licenses:
104
104
  - MIT
105
105
  metadata: {}
106
- post_install_message:
107
106
  rdoc_options: []
108
107
  require_paths:
109
108
  - lib
@@ -118,8 +117,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
118
117
  - !ruby/object:Gem::Version
119
118
  version: '0'
120
119
  requirements: []
121
- rubygems_version: 3.5.16
122
- signing_key:
120
+ rubygems_version: 3.6.2
123
121
  specification_version: 4
124
122
  summary: Validate license plate numbers for countries that support it.
125
123
  test_files:
data/.travis.yml DELETED
@@ -1,20 +0,0 @@
1
- language: ruby
2
-
3
- notifications:
4
- email: false
5
-
6
- rvm:
7
- - 2.0.0
8
- - 2.1.1
9
- - jruby-19mode
10
- - ruby-head
11
-
12
- matrix:
13
- allow_failures:
14
- - rvm: jruby-19mode
15
- - rvm: ruby-head
16
-
17
- gemfile:
18
- - gemfiles/activemodel-4
19
- - gemfiles/activemodel-3-2
20
- - gemfiles/standalone