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, flexible, letterify, method_missing, numerify, parse, rand_in_range, regexify, translate

Class Method Details

.invalidObject



16
17
18
# File 'lib/faker/id_number.rb', line 16

def invalid
  _translate 'invalid'
end

.ssn_validObject



20
21
22
23
24
# File 'lib/faker/id_number.rb', line 20

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



12
13
14
# File 'lib/faker/id_number.rb', line 12

def valid
  _translate 'valid'
end