Skip to content

Commit

Permalink
Merge pull request #4 from jonsgreene/master
Browse files Browse the repository at this point in the history
changed gsub to allow asterisks so that washington can be validated
  • Loading branch information
amedeiros authored Jul 31, 2016
2 parents 0a91b23 + d10a3a8 commit 3410c6f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/dl_validator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ def self.invalid?(dl_number, dl_state)
# Stop and return true if either dl_number or dl_state are nil
return true if dl_number.nil? or dl_state.nil?

# Downcase and remove non-word characters
dl_number = dl_number.to_s.upcase.gsub(/(\W|_)*/, '')
# Downcase and remove non-word characters that are not asterisks
dl_number = dl_number.to_s.upcase.gsub(/[^a-zA-Z0-9\*]*/, '')
dl_state = dl_state.to_s.upcase.gsub(/(\W|\d|_)*/, '')

# Stop here and return true if the state does not exist
Expand Down
10 changes: 10 additions & 0 deletions test/test_dl_validator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,16 @@ class DlValidatorTest < Test::Unit::TestCase
assert !DlValidator.invalid?(license, 'FL')
end

should 'handle the state of Washington with an (*) in the License and should be valid' do
license = 'DEOLID*237NS'
assert DlValidator.valid?(license, 'WA')
end

should 'handle the state of Washington with an (*) in the License and should be invalid' do
license = 'DEOLID*23dsdf7NS'
assert !DlValidator.valid?(license, 'WA')
end

should 'return true for a nil drivers_license_number' do
assert DlValidator.invalid?(drivers_license_number=nil, 'FL')
end
Expand Down

0 comments on commit 3410c6f

Please sign in to comment.