2.0.3 • Published 2 years ago

mongoose-imei v2.0.3

Weekly downloads
1
License
MIT
Repository
github
Last release
2 years ago

mongoose-imei

Build Status

Gives you the Imei type to use in your schemas, complete with validation using node-imei library. https://en.wikipedia.org/wiki/International_Mobile_Equipment_Identity

Usage

Start with an npm install --save mongoose-imei

const mongoose = require('mongoose');
const imei = require('mongoose-imei');

const Schema = mongoose.Schema;

imei.loadType(mongoose);

const PhoneSchema = new Schema({
  phone: { type: Schema.Types.Imei },
});

const PhoneModel = mongoose.model('Phone', PhoneSchema);

const phone = new PhoneModel({
  imei: '351680077319519',
});

This type will validate the entry and return an error if a wrong value is given.