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 {
59
59
}
60
60
}
61
61
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
+
62
80
export function formatPhoneDynamic ( input : string ) : {
63
81
formatted : string ;
64
82
type : PhoneType ;
@@ -107,7 +125,7 @@ export function formatPhoneDynamic(input: string): {
107
125
export function validatePhoneOnBlur ( input : string ) : boolean {
108
126
const digits = stripNonDigits ( input ) ;
109
127
const type = detectPhoneType ( digits ) ;
110
- const max = getMaxLengthByType ( type ) ;
111
128
if ( type === 'unknown' ) return false ;
112
- return digits . length === max ;
129
+ const { min, max } = getLengthRangeByType ( type ) ;
130
+ return digits . length >= min && digits . length <= max ;
113
131
}
You can’t perform that action at this time.
0 commit comments