swagger.io
swagger.io copied to clipboard
SSN Example regex is not correct
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}$'