File tree Expand file tree Collapse file tree 4 files changed +10
-8
lines changed Expand file tree Collapse file tree 4 files changed +10
-8
lines changed Original file line number Diff line number Diff line change @@ -2,10 +2,10 @@ module github.com/ralvarezdev/go-validator
22
33go 1.23.4
44
5- require github.com/ralvarezdev/go-flags v0.3.2 // indirect
5+ require github.com/ralvarezdev/go-flags v0.3.3 // indirect
66
77require (
88 github.com/ralvarezdev/go-logger v0.4.6
99 github.com/ralvarezdev/go-reflect v0.2.4
10- github.com/ralvarezdev/go-strings v0.1.9
10+ github.com/ralvarezdev/go-strings v0.1.11
1111)
Original file line number Diff line number Diff line change 11github.com/ralvarezdev/go-flags v0.3.2 h1:l3f62CD5NysLAJH5XqSRGiakU/dn4pTGdX4yaBlAmMw =
22github.com/ralvarezdev/go-flags v0.3.2 /go.mod h1:R3yVBYvzwqfOp26LidaiJ/zftVAnPC3pKunVpV/vosE =
3+ github.com/ralvarezdev/go-flags v0.3.3 h1:1NpwdSD+uCMF5NP+szJmq/mXqNFZwrzKAfDNZOznDEQ =
4+ github.com/ralvarezdev/go-flags v0.3.3 /go.mod h1:R3yVBYvzwqfOp26LidaiJ/zftVAnPC3pKunVpV/vosE =
35github.com/ralvarezdev/go-logger v0.4.6 h1:eZalm0WAdNuhzbaVh5D7gC6AFztdpqE/GQfjH2pipyE =
46github.com/ralvarezdev/go-logger v0.4.6 /go.mod h1:zxuMDHqtV2eoJYtmo219lima0ZSk4p/AGj/cCc390P8 =
57github.com/ralvarezdev/go-reflect v0.2.4 h1:PLyzbrdNvUiRzpxSHuI9b7hJEhFes22gjNLZkbjn5AQ =
68github.com/ralvarezdev/go-reflect v0.2.4 /go.mod h1:jv3EqQfUixWtNeJd/Rnzf0IDcYZ1z3GApRdAGQHdHZQ =
7- github.com/ralvarezdev/go-strings v0.1.9 h1:FyYTJW+EnkWFp5C9GsK6wTt3rXIwPt3mUbsTAFUuAT8 =
8- github.com/ralvarezdev/go-strings v0.1.9 /go.mod h1:8sFOqmPJpqzS7bTjf91EzUCITnwpmkfifwY80GxV5r8 =
9+ github.com/ralvarezdev/go-strings v0.1.11 h1:3Vla7fGOs+4nyQ3NVaFz+XRP3CTv5JheGt0PXryBcMo =
10+ github.com/ralvarezdev/go-strings v0.1.11 /go.mod h1:8sFOqmPJpqzS7bTjf91EzUCITnwpmkfifwY80GxV5r8 =
Original file line number Diff line number Diff line change 55)
66
77var (
8- ErrFoundWhitespaces = errors .New ("username cannot contain whitespaces " )
8+ ErrMustBeAlphanumeric = errors .New ("username must be have alphanumeric characters " )
99)
Original file line number Diff line number Diff line change @@ -134,11 +134,11 @@ func (d *DefaultService) Username(
134134 username string ,
135135 validations * govalidatormappervalidation.StructValidations ,
136136) {
137- // Check if the username contains a whitespace
138- if strings . Contains (username , " " ) {
137+ // Check if the username contains non-alphanumeric characters
138+ if gostringscount . Alphanumeric (username ) != len ( username ) {
139139 validations .AddFieldValidationError (
140140 usernameField ,
141- govalidatorfieldusername .ErrFoundWhitespaces ,
141+ govalidatorfieldusername .ErrMustBeAlphanumeric ,
142142 )
143143 }
144144}
You can’t perform that action at this time.
0 commit comments