Sha256: 705e25d10c40570213436abc4b764635404c7d1a375deb7a66ce03282f476de0

Contents?: true

Size: 507 Bytes

Versions: 1

Compression:

Stored size: 507 Bytes

Contents

module Faker
  module Medical
    class SSN < Base

      SSN_REGEX = /(?!(000|666|9))\d{3}(-|\s)?(?!00)\d{2}(-|\s)?(?!0000)\d{4}/

      class << self
        # English social security number has the format xxx-xx-xxxx
        # numerify won't always generate an SSN that matches correctly
        # repeat until we have a valid SSN
        def ssn
          loop do
            val = numerify('###-##-####')
            return val if SSN_REGEX =~ val
          end
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
faker-medical-0.5.2 lib/faker/medical/ssn.rb