File tree Expand file tree Collapse file tree 1 file changed +20
-2
lines changed
Expand file tree Collapse file tree 1 file changed +20
-2
lines changed Original file line number Diff line number Diff line change @@ -59,6 +59,24 @@ export function getMaxLengthByType(type: PhoneType): number {
5959 }
6060}
6161
62+ export function getLengthRangeByType ( type : PhoneType ) : { min : number ; max : number } {
63+ switch ( type ) {
64+ case 'seoul' :
65+ return { min : 9 , max : 10 } ;
66+ case 'region' :
67+ return { min : 10 , max : 11 } ;
68+ case 'legacyMobile' :
69+ return { min : 10 , max : 11 } ;
70+ case 'mobile' :
71+ case 'voip' :
72+ return { min : 11 , max : 11 } ;
73+ case 'special' :
74+ return { min : 8 , max : 8 } ;
75+ default :
76+ return { min : 11 , max : 11 } ;
77+ }
78+ }
79+
6280export function formatPhoneDynamic ( input : string ) : {
6381 formatted : string ;
6482 type : PhoneType ;
@@ -107,7 +125,7 @@ export function formatPhoneDynamic(input: string): {
107125export function validatePhoneOnBlur ( input : string ) : boolean {
108126 const digits = stripNonDigits ( input ) ;
109127 const type = detectPhoneType ( digits ) ;
110- const max = getMaxLengthByType ( type ) ;
111128 if ( type === 'unknown' ) return false ;
112- return digits . length === max ;
129+ const { min, max } = getLengthRangeByType ( type ) ;
130+ return digits . length >= min && digits . length <= max ;
113131}
You can’t perform that action at this time.
0 commit comments