change validation check name

This commit is contained in:
Samuel Newman
2025-07-03 14:59:11 +03:00
parent a55992c776
commit 8fc9bc4e35
3 changed files with 6 additions and 6 deletions
+2 -2
View File
@@ -18,7 +18,7 @@ describe('handle validation', () => {
}) })
const invalid = [ const invalid = [
['al', 'bsky.social', 'frontLengthLongEnough'], ['al', 'bsky.social', 'frontLengthNotTooShort'],
['-alice', 'bsky.social', 'hyphenStartOrEnd'], ['-alice', 'bsky.social', 'hyphenStartOrEnd'],
['alice-', 'bsky.social', 'hyphenStartOrEnd'], ['alice-', 'bsky.social', 'hyphenStartOrEnd'],
['%%%', 'bsky.social', 'handleChars'], ['%%%', 'bsky.social', 'handleChars'],
@@ -28,7 +28,7 @@ describe('handle validation', () => {
'my-custom-pds-with-long-name.social', 'my-custom-pds-with-long-name.social',
'frontLengthNotTooLong', 'frontLengthNotTooLong',
], ],
['al', 'my-custom-pds-with-long-name.social', 'frontLengthLongEnough'], ['al', 'my-custom-pds-with-long-name.social', 'frontLengthNotTooShort'],
['a'.repeat(300), 'toolong.com', 'totalLength'], ['a'.repeat(300), 'toolong.com', 'totalLength'],
] satisfies [string, string, keyof IsValidHandle][] ] satisfies [string, string, keyof IsValidHandle][]
it.each(invalid)( it.each(invalid)(
+2 -2
View File
@@ -36,7 +36,7 @@ export function sanitizeHandle(handle: string, prefix = ''): string {
export interface IsValidHandle { export interface IsValidHandle {
handleChars: boolean handleChars: boolean
hyphenStartOrEnd: boolean hyphenStartOrEnd: boolean
frontLengthLongEnough: boolean frontLengthNotTooShort: boolean
frontLengthNotTooLong: boolean frontLengthNotTooLong: boolean
totalLength: boolean totalLength: boolean
overall: boolean overall: boolean
@@ -53,7 +53,7 @@ export function validateServiceHandle(
handleChars: handleChars:
!str || (VALIDATE_REGEX.test(fullHandle) && !str.includes('.')), !str || (VALIDATE_REGEX.test(fullHandle) && !str.includes('.')),
hyphenStartOrEnd: !str.startsWith('-') && !str.endsWith('-'), hyphenStartOrEnd: !str.startsWith('-') && !str.endsWith('-'),
frontLengthLongEnough: str.length >= 3, frontLengthNotTooShort: str.length >= 3,
frontLengthNotTooLong: str.length <= MAX_SERVICE_HANDLE_LENGTH, frontLengthNotTooLong: str.length <= MAX_SERVICE_HANDLE_LENGTH,
totalLength: fullHandle.length <= 253, totalLength: fullHandle.length <= 253,
} }
+2 -2
View File
@@ -200,7 +200,7 @@ export function StepHandle() {
<RequirementIcon <RequirementIcon
state={ state={
validCheck.handleChars && validCheck.hyphenStartOrEnd validCheck.handleChars && validCheck.hyphenStartOrEnd
? !validCheck.frontLengthLongEnough ? !validCheck.frontLengthNotTooShort
? 'initial' ? 'initial'
: 'valid' : 'valid'
: 'invalid' : 'invalid'
@@ -220,7 +220,7 @@ export function StepHandle() {
<Requirement> <Requirement>
<RequirementIcon <RequirementIcon
state={ state={
!validCheck.frontLengthLongEnough !validCheck.frontLengthNotTooShort
? 'initial' ? 'initial'
: validCheck.frontLengthNotTooLong && validCheck.totalLength : validCheck.frontLengthNotTooLong && validCheck.totalLength
? 'valid' ? 'valid'