You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The regular expression includes this optional (0 or 1) character class [ -]? as the separator between each segment of the social security number, meaning it supports each of the following formats:
123-12-1234
123 12 1234
123-12 1234
123 12-1234
123 121234
12312 1234
12312-1234
123-121234
123121234
This presents at least two issues:
The length check means that social security numbers with formatting stripped (123121234) will not pass the validation, despite the regular expression matching it. Since it's pretty common to deal with unformatted values, it might be worth supporting strings with a length of 9 in addition to 11
The regular expression is a bit too loose with formatting. Mixed usage of spaces and hyphens is not something that I would expect to pass the validation. The regular expression should probably enforce consistent separators.
Package version eg. v9, v10:
v10
Issue, Question or Enhancement:
The
ssn
validation is composed of two checks:validator/baked_in.go
Line 427 in e20b948
validator/regexes.go
Line 52 in e20b948
The regular expression includes this optional (0 or 1) character class
[ -]?
as the separator between each segment of the social security number, meaning it supports each of the following formats:123-12-1234
123 12 1234
123-12 1234
123 12-1234
123 121234
12312 1234
12312-1234
123-121234
123121234
This presents at least two issues:
The length check means that social security numbers with formatting stripped (
123121234
) will not pass the validation, despite the regular expression matching it. Since it's pretty common to deal with unformatted values, it might be worth supporting strings with a length of9
in addition to11
The regular expression is a bit too loose with formatting. Mixed usage of spaces and hyphens is not something that I would expect to pass the validation. The regular expression should probably enforce consistent separators.
Code sample, to showcase or reproduce:
The text was updated successfully, but these errors were encountered: