![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
mongoose-intl-phone-number
Advanced tools
A configurable mongoose.js plugin that parses phone numbers and stores data about them in the document.
This module takes a string of numbers and determines their validity as well as returns data about the phone numbers. This module is based on Google's libphonenumber.
A phone number is provided on the document, during the pre-save/validate hook (you can specify), it runs the phone number through libphonenumber and stores the data returned onto fields in the document model.
Applications that accept international phone numbers should use this plugin to gather and store information about the number such as country code, national format, etc.
npm install --save mongoose-intl-phone-number
Validates a phone number against google's libphonenumber, otherwise returns a validation error.
Example
var mongooseIntlPhoneNumber = require('mongoose-intl-phone-number');
var schema = Schema({...});
schema.plugin(mongooseIntlPhoneNumber, {
hook: 'validate',
phoneNumberField: 'phoneNumber',
nationalFormatField: 'nationalFormat',
internationalFormat: 'internationalFormat',
countryCodeField: 'countryCode',
});
Use it with a model...
var Customer = mongoose.model('Customer');
var customer = new Customer({
firstName: 'test',
lastName: 'customer',
customerType: 'testing',
phoneNumber: '+18888675309',
email: 'test@testing.com'
});
customer.save();
Resulting document...
{
"firstName": "test",
"lastName": "customer",
"customerType": "testing",
"phoneNumber": "+18888675309",
"nationalFormat": "(888) 867-5309",
"internationalFormat": "+1 888-867-5309"
"countryCode": "US"
}
Attaches the mongoose document hook and parses the phone number that is provided.
Kind: inner method of mongooseIntlPhoneNumber
Param | Type | Default | Description |
---|---|---|---|
schema | object | Mongoose schema | |
[options] | object | ||
[options.hook] | string | "validate" | |
[options.phoneNumberField] | string | "phoneNumber" | |
[options.nationalFormatField] | string | "nationalFormat" | |
[options.internationalFormatField] | string | "internationalFormat" | |
[options.countryCodeField] | string | "countryCode" |
FAQs
A configurable mongoose.js plugin that parses phone numbers and stores data about them in the document.
We found that mongoose-intl-phone-number demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.