fix and update
This commit is contained in:
10
apps/frontend/lib/pin-input.ts
Normal file
10
apps/frontend/lib/pin-input.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
export const PIN_MIN_LENGTH = 4;
|
||||
export const PIN_MAX_LENGTH = 6;
|
||||
|
||||
export function sanitizePinInput(value: string, maxLength: number = PIN_MAX_LENGTH): string {
|
||||
return value.replace(/\D/g, '').slice(0, maxLength);
|
||||
}
|
||||
|
||||
export function isPinInputComplete(value: string, minLength: number = PIN_MIN_LENGTH): boolean {
|
||||
return /^\d+$/.test(value) && value.length >= minLength && value.length <= PIN_MAX_LENGTH;
|
||||
}
|
||||
Reference in New Issue
Block a user