-
Notifications
You must be signed in to change notification settings - Fork 84
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor: use validator's isEmail for validating email domains #386
Conversation
…nd email domains with 'bob')
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lgtm!
…dation function to directive too
Wait ah, I broke the build because of wrong import path. Will fix it on my end first... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm! The second error is because you used import ... as ...
syntax in a Javascript file. Our app only supports import syntax in Typescript files
Ah! I see |
src/public/modules/forms/admin/directives/validate-email-domain-from-text.directive.js
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Update import to be relative before merging; tests are currently passing probably because they do not reach the invalid directive
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
Problem
Currently, email domain validation is done via regex. We would like to use
validator.isEmail
to validate email domains. In order to useisEmail
, we will prepend email domains with a string i.e. "bob".Closes #54
Interesting things to note
I put in a lot of thought before finally deciding on "bob". I wanted something short and not nonsensical like abc.
I received these linting errors:
As such, I had to do the following extra stuff:
const EmailFieldSchema: Schema<IEmailFieldSchema> = ...
instead of leaving it alone (originallyconst EmailFieldSchema = ...
const { validateEmailDomains } = require('shared/util/email-domain-validation')
instead ofimport { ... } from '...'
.I also found out that
src/app/models/agency.server.model.ts
validates email domains bymatch: [/.+\..+/, 'Please fill a valid email domain.'],
.