Skip to content

Commit 38a6e18

Browse files
committed
Lint: Perform nil check earlier
1 parent 53f7bd1 commit 38a6e18

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

email.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,17 @@ func (e Email) MarshalJSON() ([]byte, error) {
2222
}
2323

2424
func (e *Email) UnmarshalJSON(data []byte) error {
25+
if e == nil {
26+
return nil
27+
}
28+
2529
var s string
2630
if err := json.Unmarshal(data, &s); err != nil {
2731
return err
2832
}
2933

3034
*e = Email(s)
31-
if e != nil && !emailRegex.MatchString(s) {
35+
if !emailRegex.MatchString(s) {
3236
return ErrValidationEmail
3337
}
3438

0 commit comments

Comments
 (0)