File tree Expand file tree Collapse file tree 1 file changed +6
-4
lines changed
Expand file tree Collapse file tree 1 file changed +6
-4
lines changed Original file line number Diff line number Diff line change @@ -15,11 +15,12 @@ var ErrValidationEmail = errors.New("email: failed to pass regex validation")
1515type Email string
1616
1717func (e Email ) MarshalJSON () ([]byte , error ) {
18- if _ , err := mail .ParseAddress (string (e )); err != nil {
18+ m , err := mail .ParseAddress (string (e ))
19+ if err != nil {
1920 return nil , ErrValidationEmail
2021 }
2122
22- return json .Marshal (string ( e ) )
23+ return json .Marshal (m . Address )
2324}
2425
2526func (e * Email ) UnmarshalJSON (data []byte ) error {
@@ -32,10 +33,11 @@ func (e *Email) UnmarshalJSON(data []byte) error {
3233 return err
3334 }
3435
35- * e = Email (s )
36- if _ , err := mail . ParseAddress ( s ); err != nil {
36+ m , err := mail . ParseAddress (s )
37+ if err != nil {
3738 return ErrValidationEmail
3839 }
3940
41+ * e = Email (m .Address )
4042 return nil
4143}
You can’t perform that action at this time.
0 commit comments