Skip to content

Commit

Permalink
Merge pull request faker-ruby#2475 from erayalkis/master
Browse files Browse the repository at this point in the history
Update regex used for Faker::Vehicle#vin
  • Loading branch information
thdaraujo authored Jun 16, 2022
2 parents 4255812 + 795173e commit e5268b3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/faker/default/vehicle.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class Vehicle < Base
VIN_LETTERS = 'ABCDEFGHJKLMNPRSTUVWXYZ'
VIN_MAP = '0123456789X'
VIN_WEIGHTS = '8765432X098765432'
VIN_REGEX = /^[A-Z0-9]{3}[A-Z0-9]{5}[A-Z0-9]{1}[A-Z0-9]{1}[A-Z0-0]{1}[A-Z0-9]{1}\d{5}$/.freeze
VIN_REGEX = /^([A-HJ-NPR-Z0-9]){3}[A-HJ-NPR-Z0-9]{5}[A-HJ-NPR-Z0-9]{1}[A-HJ-NPR-Z0-9]{1}[A-HJ-NPR-Z0-0]{1}[A-HJ-NPR-Z0-9]{1}\d{5}$/.freeze
SG_CHECKSUM_WEIGHTS = [3, 14, 2, 12, 2, 11, 1].freeze
SG_CHECKSUM_CHARS = 'AYUSPLJGDBZXTRMKHEC'

Expand Down
5 changes: 5 additions & 0 deletions test/faker/default/test_faker_vehicle.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

class TestFakerVehicle < Test::Unit::TestCase
WORD_MATCH = /\w+\.?/.freeze
VALIDITY_MATCH = /^([A-HJ-NPR-Z0-9])+/.freeze

def setup
@tester = Faker::Vehicle
Expand All @@ -13,6 +14,10 @@ def test_vin
assert_match Faker::Vehicle::VIN_REGEX, @tester.vin
end

def test_vin_validity
assert_match VALIDITY_MATCH, @tester.vin
end

def test_manufacture
assert_match WORD_MATCH, @tester.manufacture
end
Expand Down

0 comments on commit e5268b3

Please sign in to comment.