Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 2 additions & 0 deletions lib/validations.accessibility.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ describe('validations.ts - Accessibility Standards & Screen Reader Aria Complian
// Assert schema function returns expected output
expect(validateGitHubUsername('octocat')).toBe(true);
expect(validateGitHubUsername('invalid--user')).toBe(false);
expect(validateGitHubUsername('a'.repeat(39))).toBe(true);
expect(validateGitHubUsername('a'.repeat(40))).toBe(false);

const validationAlert = {
role: 'alert',
Expand Down
4 changes: 2 additions & 2 deletions lib/validations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export function toDimensionValue(val?: string): number | undefined {
}

export function validateGitHubUsername(username: string): boolean {
return /^[a-z\d](?:[a-z\d]|-(?=[a-z\d])){0,38}$/i.test(username);
return GITHUB_USERNAME_REGEX.test(username);
}

/**
Expand Down Expand Up @@ -141,7 +141,7 @@ const timeZoneParam = z
.optional()
.refine(isValidTimeZone, { message: 'Invalid timezone' });

export const GITHUB_USERNAME_REGEX = /^[a-zA-Z0-9](?:[a-zA-Z0-9]|-(?=[a-zA-Z0-9]))*$/;
export const GITHUB_USERNAME_REGEX = /^[a-zA-Z0-9](?:[a-zA-Z0-9]|-(?=[a-zA-Z0-9])){0,38}$/;

export const githubUsernameSchema = z
.string({ error: 'Invalid GitHub username' })
Expand Down
Loading