Skip to content

Conversation

@dmendelowitz
Copy link
Contributor

Summary

Adding a custom format to the config validator that checks if a string has the format of emails separated by commas, for example: [email protected],[email protected]. This new format is used to validate the notificationInfo.to field in the config

New behavior

The config validator will now ensure that the notificationInfo.to field of the config is either an array of emails or a string of emails separated by commas

Code changes

  • Custom format, comma-separated-emails, added to configValidator.js which splits a string at any commas, strips excess whitespace and then validates the resulting strings against Ajv's email format regex
  • config.schema.json updated to use comma-separated-emails for notificationInfo.to

Testing guidance

Here are some variations to test:

  • [email protected] a single email should still be valid
  • test#example.com a single invalid email should not be valid
  • [email protected],[email protected] emails separated by comma should be valid
  • [email protected],demo&example.com should not be valid if any item is not a valid email
  • Be sure to test any other cases you can think of in case I missed something

@dmendelowitz
Copy link
Contributor Author

Also, I sort of just assumed it would be a good thing to strip excess whitespace, but does anyone actually know if notificationInfo.to needs to be strictly commas with no spaces?

@Dtphelan1 Dtphelan1 self-assigned this Jul 1, 2021
Copy link
Contributor

@Dtphelan1 Dtphelan1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good. Tested with both an array of strings and a single string with multiple, commas-separated emails and things look good. Great work!

@julianxcarter julianxcarter self-assigned this Jul 1, 2021
Copy link
Contributor

@julianxcarter julianxcarter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Validation works flawlessly for me, both within the array and also in a comma-separated string. Nice work!

@julianxcarter julianxcarter merged commit bae0239 into develop Jul 1, 2021
@julianxcarter julianxcarter deleted the comma-email-schema branch July 1, 2021 17:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants