Gathering detailed insights and metrics for @optima-lib/phone-utils
Gathering detailed insights and metrics for @optima-lib/phone-utils
Gathering detailed insights and metrics for @optima-lib/phone-utils
Gathering detailed insights and metrics for @optima-lib/phone-utils
npm install @optima-lib/phone-utils
Typescript
Module System
Node Version
NPM Version
TypeScript (80.89%)
JavaScript (11.54%)
HTML (4.66%)
SCSS (2.9%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
20 Commits
1 Watchers
1 Branches
1 Contributors
Updated on Jun 11, 2024
Latest Version
17.0.0
Package Id
@optima-lib/phone-utils@17.0.0
Unpacked Size
34.92 kB
Size
7.76 kB
File Count
14
NPM Version
9.5.0
Node Version
18.15.0
Published on
Jun 11, 2024
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
2
3
This an Angular library (and can be used with Angular projects only).
It uses libphonenumber-js to provide developers with the angular way of formatting and validating phone numbers.
Angular | OptimaLib |
---|---|
17.x | 17.x |
16.x | 16.x |
15.x | 15.x |
14.x | 14.x |
13.x | 13.x |
npm install --save @optima-lib/phone-utils
import { OptimaPhoneUtilsService } from '@optima-lib/phone-utils';
// Inject in your component or service:
constructor(private phoneUtils: OptimaPhoneUtilsService) { }
getInternational(value: string, country: string): string - Transform a given phone number to international format
Param | Description |
---|---|
value | Phone numer |
country | Two-letters country code |
getNational(value: string, country: string): string - Transform a given phone number to its national format
Param | Description |
---|---|
value | Phone numer |
country | Two-letters country code |
getPlain(value: string, country: string): string - International format without inner spaces (PNF.E164)
Param | Description |
---|---|
value | Phone numer |
country | Two-letters country code |
isValid(value: string, country: string): boolean - General purpose validator. Use in conjunction with other services and components. The method will return true when arguments relates to a phone number from the selected country.
Param | Description |
---|---|
value | Phone numer |
country | Two-letters country code |
isValidFormControl(country: string): boolean - Reactive form validator. It will set phoneInvalid property in related form control error's object.
Param | Description |
---|---|
country | Two-letters country code. |
Usage:
// app.component.ts
constructor(public phoneValidatorService: OptimaPhoneValidatorService) { }
public getForm() {
this.form = new FormGroup({
phone: new FormControl('', [
Validators.required,
this.phoneValidatorService.isValidPhone('BG')
])
});
}
// app.component.html
<span *ngIf="form.get('phone')?.errors?.phoneInvalid">{{ 'FORM.ERROR.PHONE_FORMAT.INVALID' | translate }}</span>
Import OptimaInternationalFormatPipe in the component where you want to use it:
import { OptimaInternationalFormatPipe } from '@optima-lib/phone-utils';
@Component({
imports: [
...,
OptimaInternationalFormatPipe
]
})
export class UserComponent() { }
And then it can be used as:
{{ '02 1234567' | internationalFormat : 'BG' }}
which will produce:
+359 2 123 4567
Import OptimaNationalFormatPipe in the component where you want to use it:
import { OptimaNationalFormatPipe } from '@optima-lib/phone-utils';
@Component({
imports: [
...,
OptimaNationalFormatPipe
]
})
export class UserComponent() { }
And then it can be used as:
{{ '02 1234567' | nationalFormat : 'BG' }}
which will produce:
02 123 4567
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
no SAST tool detected
Details
Reason
Found 0/20 approved changesets -- score normalized to 0
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
license file not detected
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
36 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-07-07
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More