diff --git a/projects/ngx-phone-mask/package.json b/projects/ngx-phone-mask/package.json index 8cafa00..9266dc1 100644 --- a/projects/ngx-phone-mask/package.json +++ b/projects/ngx-phone-mask/package.json @@ -1,6 +1,6 @@ { "name": "ngx-phone-mask", - "version": "3.2.1", + "version": "3.2.2", "peerDependencies": { "@angular/common": "^6.0.0-rc.0 || ^6.0.0", "@angular/core": "^6.0.0-rc.0 || ^6.0.0", diff --git a/projects/ngx-phone-mask/src/lib/ngx-phone-mask.pipe.ts b/projects/ngx-phone-mask/src/lib/ngx-phone-mask.pipe.ts index ed408ce..b7b9bc8 100644 --- a/projects/ngx-phone-mask/src/lib/ngx-phone-mask.pipe.ts +++ b/projects/ngx-phone-mask/src/lib/ngx-phone-mask.pipe.ts @@ -8,6 +8,10 @@ import { mask } from './utils'; export class NgxPhoneMaskPipe implements PipeTransform { transform(value: string): string { + if (!value) { + return ''; + } + return conformToMask( value, mask(), diff --git a/projects/ngx-phone-mask/src/lib/utils.ts b/projects/ngx-phone-mask/src/lib/utils.ts index 8149c97..df26da4 100644 --- a/projects/ngx-phone-mask/src/lib/utils.ts +++ b/projects/ngx-phone-mask/src/lib/utils.ts @@ -5,7 +5,7 @@ export const clean = (number) => { }; export const mask = () => (rawValue) => { - if (!rawValue || clean(rawValue).length <= 12) { + if (clean(rawValue).length <= 12) { return ['+', /[1-9]/, ' ', '(', /[1-9]/, /\d/, /\d/, ')', ' ', /\d/, /\d/, /\d/, '-', /\d/, /\d/, '-', /\d/, /\d/]; }