13966 Sample email verifier service + component#399
13966 Sample email verifier service + component#399severinbeauvais wants to merge 1 commit intobcgov:mainfrom
Conversation
Codecov Report
@@ Coverage Diff @@
## main #399 +/- ##
==========================================
- Coverage 83.26% 83.15% -0.11%
==========================================
Files 174 175 +1
Lines 3238 3266 +28
Branches 508 524 +16
==========================================
+ Hits 2696 2716 +20
- Misses 541 549 +8
Partials 1 1
|
42a5b4d to
39cbc09
Compare
| valid = await EmailVerificationService.isValidEmail(contactInfo.email) | ||
| } catch { | ||
| valid = true // if error, assume email is valid | ||
| } |
There was a problem hiding this comment.
Can't use .catch(err => ...) here because we can't mock it in the unit tests.
| if (!result) throw new Error('Invalid API response') | ||
| // accept OK or UNKNOWN status | ||
| return (result === ResultCodes.OK || result === ResultCodes.UNKNOWN) | ||
| }) |
There was a problem hiding this comment.
Don't catch errors here -- let the caller decide what to do about exceptions.
| @@ -0,0 +1,87 @@ | |||
| <template> | |||
There was a problem hiding this comment.
If we like the way this component works, it could easily be moved to bcrs-shared-components repo.
We'd have to pass in a reference to the email verification service (as we do for NAICS lookup).
| */ | ||
| static async isValidEmail ( | ||
| email: string, | ||
| apiUrl = 'https://api.millionverifier.com/api/v3', |
There was a problem hiding this comment.
I don't think we need external config for this since there's only 1 endpoint (no dev or test).
To prevent burning up credits while testing, this method automatically returns "valid" if no API key is configured.
39cbc09 to
5721acc
Compare
- try email verifier in Business Contact Info - added Verified Email component - try email sub-component in Documents Delivery + simplify logic - misc cleanup - added/updated unit tests
5721acc to
6148f84
Compare
Issue #: bcgov/entity#13966
This PR contains prototype code for exploration/discussion. Feel free to check it out and run it locally to see what it looks like, but I don't expect we'll be merging this code as it is currently.
Description of changes:
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of the bcrs-entities-create-ui license (Apache 2.0).