Skip to content

Commit

Permalink
refactor (shared): improve types in validationRegex
Browse files Browse the repository at this point in the history
  • Loading branch information
EvAvKein committed May 20, 2024
1 parent 2c2337b commit d586141
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions shared/objects/validationRegex.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,20 @@ export const shared = {
phoneNumber: /^[0-9]{9}$/,
countryCode: /^[1-9][0-9]{0,2}$/,
timezone: new RegExp(timezoneValues.reduce((prev, current) => prev + "|" + current)),
};
} as const;

export const org: Omit<Record<keyof Org, RegExp>, "id" | "customInvCssOverrides"> = {
export const org = {
name: /^(?!\s)[\w '\-]{1,30}(?<!\s)$/u,
color: /^[0-9a-fA-F]{6}$/,
customInvCss: /^(?!.*(?:behavior:|expression|javascript:|data:|.js|@import|url\\()))[\s\S]{0,10000}$/,
};
} as const satisfies Omit<Record<keyof Org, RegExp>, "id" | "customInvCssOverrides">;

export const agent: Omit<Record<keyof Agent, RegExp>, "id" | "orgId" | "internals"> = {
export const agent = {
name: /^(?!\s)[\w '\-]{1,30}(?<!\s)$/u, // max is not large enough for some names, but i'll make it clear that this is the name that'll appear on invites and should therefore be presentable. but also that approach might be too strict... i'll just have to see if using the unabbreviated versions of long names is that important to their cultures, even in business contexts, to be worth the design consequences
department: /^(?!\s)[\w '\-]{2,50}(?<!\s)$/u, // same as above, max length is subject to change
countryCode: shared.countryCode,
timezone: shared.timezone,
} as const;
} as const satisfies Omit<Record<keyof Agent, RegExp>, "id" | "orgId" | "internals">;

export const callRecipient = {
name: /^(?!\s)[\w '\-]{1,30}(?<!\s)$/u,
Expand All @@ -33,9 +33,9 @@ export const callRecipient = {
export const inviteNotes = {
forRecipient: /^.{0,250}$/,
forOrg: /^.{0,500}$/,
};
export const invite: Omit<recursiveRecord<Invite, RegExp>, "id" | "orgId" | "agentId" | "expiry"> = {
} as const;
export const invite = {
recipient: callRecipient,
secCallDuration: /^[1-9][0-9]{0,2}$/,
notes: inviteNotes,
};
} as const satisfies Omit<recursiveRecord<Invite, RegExp>, "id" | "orgId" | "agentId" | "expiry">;

0 comments on commit d586141

Please sign in to comment.