Skip to contents

Simple email format validation using regex pattern.

Usage

validate_email_fmt(email, allow_disp_name = FALSE)

Arguments

email

Character string to validate as email address.

allow_disp_name

Logical. If TRUE, accepts "Display Name " format in addition to plain email addresses. Default FALSE.

Value

Logical. TRUE if email format is valid, FALSE otherwise.

Details

Uses a basic regex pattern to validate email format. This is not exhaustive but catches most common formatting errors. Pattern checks for:

  • At least one character before @

  • @ symbol

  • At least one character after @

  • Dot (.) in domain

  • At least two characters after final dot

When allow_disp_name = TRUE, also accepts RFC 5322 style addresses like "Display Name email@example.com".

See also

Examples

validate_email_fmt("user@example.com")
#> [1] TRUE
validate_email_fmt("invalid.email")
#> [1] FALSE
validate_email_fmt("Display Name <user@example.com>", allow_disp_name = TRUE)
#> [1] TRUE