-
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #58 from ALanguillaume/fix-email-validation
fix: email with dashes are now considered valid
- Loading branch information
Showing
3 changed files
with
27 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -214,8 +214,10 @@ attachments <- function(sg_mail, path, name, content_id) { | |
|
||
## FIX [email protected] return TRUE | ||
email_chk <- function(email) { | ||
grepl("^([a-z0-9_\\.-\\+]+)@([0-9a-z\\.-]+)\\.([a-z\\.]{2,6})$", | ||
email) | ||
grepl( | ||
pattern = "^[[:alnum:]._-]+@[[:alnum:].-]+$", | ||
x = email | ||
) | ||
} | ||
|
||
sg_mail_chk <- function(sg_mail) { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# This file is part of the standard setup for testthat. | ||
# It is recommended that you do not modify it. | ||
# | ||
# Where should you do additional test configuration? | ||
# Learn more about the roles of various files in: | ||
# * https://r-pkgs.org/testing-design.html#sec-tests-files-overview | ||
# * https://testthat.r-lib.org/articles/special-files.html | ||
|
||
library(testthat) | ||
library(sendgridr) | ||
|
||
test_check("sendgridr") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
test_that("Email validation works", { | ||
emails <- c( | ||
"[email protected]", | ||
"[email protected]" | ||
) | ||
expect_true( | ||
all( | ||
email_chk(emails) | ||
) | ||
) | ||
}) |