Class: Faker::IDNumber

Inherits:
Base
  • Object
show all
Defined in:
lib/faker/id_number.rb

Constant Summary collapse

INVALID_SSN =
[
    /0{3}-\d{2}-\d{4}/,
    /\d{3}-0{2}-\d{4}/,
    /\d{3}-\d{2}-0{4}/,
    /666-\d{2}-\d{4}/,
    /9\d{2}-\d{2}-\d{4}/
]

Constants inherited from Base

Base::Letters, Base::Numbers, Base::ULetters

Class Method Summary collapse

Methods inherited from Base

bothify, fetch, fetch_all, flexible, letterify, method_missing, numerify, parse, rand, rand_in_range, regexify, sample, shuffle, translate, unique, with_locale

Class Method Details

.invalidObject



18
19
20
# File 'lib/faker/id_number.rb', line 18

def invalid
  _translate('invalid')
end

.ssn_validObject



22
23
24
25
26
# File 'lib/faker/id_number.rb', line 22

def ssn_valid
  ssn = regexify(/[0-8]\d{2}-\d{2}-\d{4}/)
  # We could still have all 0s in one segment or another
  INVALID_SSN.any? { |regex| regex =~ ssn } ? ssn_valid : ssn
end

.validObject



14
15
16
# File 'lib/faker/id_number.rb', line 14

def valid
  _translate('valid')
end