Skip to content
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

feat: support allow or deny config in validateEmail & deprecate block config #2661

Merged
merged 5 commits into from
Jan 14, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions arcjet/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -462,6 +462,8 @@ const validateEmailOptions = createValidator({
validations: [
{ key: "mode", required: false, validate: validateMode },
{ key: "block", required: false, validate: validateEmailTypes },
blaine-arcjet marked this conversation as resolved.
Show resolved Hide resolved
{ key: "allow", required: false, validate: validateEmailTypes },
{ key: "deny", required: false, validate: validateEmailTypes },
{
key: "requireTopLevelDomain",
required: false,
Expand Down Expand Up @@ -522,15 +524,15 @@ type BotOptionsDeny = {

export type BotOptions = BotOptionsAllow | BotOptionsDeny;

type EmailOptionsAllow = {
export type EmailOptionsAllow = {
mode?: ArcjetMode;
allow: ArcjetEmailType[];
deny?: never;
requireTopLevelDomain?: boolean;
allowDomainLiteral?: boolean;
};

type EmailOptionsDeny = {
export type EmailOptionsDeny = {
mode?: ArcjetMode;
allow?: never;
deny: ArcjetEmailType[];
Expand Down Expand Up @@ -980,11 +982,11 @@ export function validateEmail(
const allowDomainLiteral = options.allowDomainLiteral ?? false;

let config: EmailValidationConfig = {
tag: "allow-email-validation-config",
tag: "deny-email-validation-config",
val: {
requireTopLevelDomain,
allowDomainLiteral,
allow: [],
deny: [],
},
};

Expand Down
Loading