swagger.io icon indicating copy to clipboard operation
swagger.io copied to clipboard

SSN Example regex is not correct

Open peteraritchie opened this issue 5 years ago • 0 comments

SSNs cannot begin with the number 9 (that signifies an ITIN, not an SSN). Also, prefixes like 666 and 333 are also not valid. Meaning the following regex does not truely validate SSNs: '^\d{3}-\d{2}-\d{4}$'

A more correct regex would be (and supports optional hyphens): '^(?!000)(?!666)(?!9)\d{3}([- ]?)(?!00)\d{2}\1(?!0000)\d{4}$'

peteraritchie avatar Jan 22 '20 18:01 peteraritchie