Skip to content

fix: allow allowUnderscore on string().email() - #3131

Open
Hashim1999164 wants to merge 1 commit into
hapijs:masterfrom
Hashim1999164:fix/email-allow-underscore
Open

fix: allow allowUnderscore on string().email()#3131
Hashim1999164 wants to merge 1 commit into
hapijs:masterfrom
Hashim1999164:fix/email-allow-underscore

Conversation

@Hashim1999164

@Hashim1999164 Hashim1999164 commented Jul 22, 2026

Copy link
Copy Markdown

Summary

  • string().email() documented and typed allowUnderscore, and addressOptions already forwards it to @hapi/address, but assertOptions rejected the key (unlike string().domain()).
  • Accept allowUnderscore in the email options allowlist and add regression coverage for underscored domains.

Closes #2972

Test plan

  • npx lab test/types/string.js -g email
  • Confirm Joi.string().email({ allowUnderscore: true }) no longer throws unknown key
  • Confirm emails like user@_abc.example.com validate only when the option is set

email() documented and typed allowUnderscore but rejected it in
assertOptions, unlike string().domain(). Accept the option so it
reaches @hapi/address validation.

Closes hapijs#2972
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.

Incorrect documentation for string().email() 'allowUnderscore' option

1 participant