File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -44,30 +44,26 @@ export function isValidFirstNumber(phone: string): boolean {
4444 : isValidMobilePhoneFirstNumber ( phone ) ;
4545}
4646
47- function tryPhoneDigits ( phone : string ) : { isValidDigits : boolean ; digits : string } {
47+ function parsePhoneDigits ( phone : string ) : { isValidDigits : boolean ; digits : string } {
4848 return { isValidDigits : ! ! phone && typeof phone === 'string' , digits : onlyNumbers ( phone ) } ;
4949}
5050
5151export function isValidMobilePhone ( phone : string ) : boolean {
52- const { isValidDigits, digits } = tryPhoneDigits ( phone ) ;
52+ const { isValidDigits, digits } = parsePhoneDigits ( phone ) ;
5353
5454 if ( ! isValidDigits ) return false ;
5555
5656 return isValidMobilePhoneLength ( digits ) && isValidMobilePhoneFirstNumber ( digits ) && isValidDDD ( digits ) ;
5757}
5858
5959export function isValidLandlinePhone ( phone : string ) : boolean {
60- const { isValidDigits, digits } = tryPhoneDigits ( phone ) ;
60+ const { isValidDigits, digits } = parsePhoneDigits ( phone ) ;
6161
6262 if ( ! isValidDigits ) return false ;
6363
6464 return isValidLandlinePhoneLength ( digits ) && isValidLandlinePhoneFirstNumber ( digits ) && isValidDDD ( digits ) ;
6565}
6666
6767export function isValid ( phone : string ) : boolean {
68- const { isValidDigits, digits } = tryPhoneDigits ( phone ) ;
69-
70- if ( ! isValidDigits ) return false ;
71-
72- return isValidLength ( digits ) && isValidFirstNumber ( digits ) && isValidDDD ( digits ) ;
68+ return isValidMobilePhone ( phone ) || isValidLandlinePhone ( phone ) ;
7369}
You can’t perform that action at this time.
0 commit comments