How can I validate US Social Security Number?

后端 未结 8 1489
鱼传尺愫
鱼传尺愫 2020-12-08 02:44

Anyone out there know how to improve this function? I\'m not worried about shortening the code, I\'m sure this could be done with better regex, I am more concerned about cor

8条回答
  •  南笙
    南笙 (楼主)
    2020-12-08 03:18

    As of 2011 SSN's are completely randomized (http://www.socialsecurity.gov/employer/randomization.html)

    The only real rules left are:

    • Cannot start with 900-999 (although the Individual Taxpayer Identification Number, which can be used like an SSN by temporary residents and undocumented/DACA/DAPA immigrants in some situations, is in the same format and does start with 9)
    • Cannot start with 666
    • Cannot start with 000
    • Must be 9 numeric digits or 11 with the 2 dashes
    • Cannot be any of the known fakes;
      • "078051120" — Woolworth Wallet Fiasco
      • "219099999" — Was used in an ad by the Social Security Administration
    • Many people exclude repeating an sequential numbers as well, although these are now technically valid, and I feel sorry for the poor schmuck's who gets assigned these.

提交回复
热议问题