Skip to content

Commit

Permalink
Merge pull request #265 from thrawn01/thrawn/val-result
Browse files Browse the repository at this point in the history
Added result to v4 validation response
  • Loading branch information
thrawn01 authored Aug 30, 2021
2 parents fd81606 + 620ddd7 commit 05b0206
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 0 deletions.
4 changes: 4 additions & 0 deletions email_validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ type EmailVerification struct {
Reasons []string
// Risk assessment for the provided email.
Risk string `json:"risk"`
// Result
Result string `json:"result"`
}

type v4EmailValidationResp struct {
Expand All @@ -59,6 +61,7 @@ type v4EmailValidationResp struct {
IsRoleAddress bool `json:"is_role_address"`
Reason []string `json:"reason"`
Risk string `json:"risk"`
Result string `json:"result"`
}

type addressParseResult struct {
Expand Down Expand Up @@ -198,6 +201,7 @@ func (m *EmailValidatorImpl) validateV4(ctx context.Context, email string, mailB
IsDisposableAddress: res.IsDisposableAddress,
IsRoleAddress: res.IsRoleAddress,
Reasons: res.Reason,
Result: res.Result,
Risk: res.Risk}, nil
}

Expand Down
1 change: 1 addition & 0 deletions email_validation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ func TestEmailValidationV4(t *testing.T) {
ensure.True(t, len(ev.Reasons) != 0)
ensure.DeepEqual(t, ev.Reasons[0], "no-reason")
ensure.DeepEqual(t, ev.Risk, "unknown")
ensure.DeepEqual(t, ev.Result, "deliverable")
}

func TestParseAddresses(t *testing.T) {
Expand Down
1 change: 1 addition & 0 deletions mock_validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ func (ms *mockServer) validateEmailV4(w http.ResponseWriter, r *http.Request) {
}
results.Reason = []string{"no-reason"}
results.Risk = "unknown"
results.Result = "deliverable"
toJSON(w, results)
}

Expand Down

0 comments on commit 05b0206

Please sign in to comment.