mongoose-type-url

2.1.0 • Public • Published

mongoose-type-url

A url field-type for Mongoose schemas

npm

Greenkeeper badge Build Status Code Climate

usage

This will validate a url, correctly:

var mongoose = require('mongoose');
require('mongoose-type-url');
 
var UserSchema = new mongoose.Schema({
    url: {
        work: mongoose.SchemaTypes.Url,
        profile: mongoose.SchemaTypes.Url
    }
});

You can also use the stuff in String type:

var UserSchema = new mongoose.Schema({
    url: {
        work: {type: mongoose.SchemaTypes.Url, required: true},
        profile: {type: mongoose.SchemaTypes.Url, required: true},
    }
});

You can also use it as an array:

var UserSchema = new mongoose.Schema({
    urls: [{type: mongoose.SchemaTypes.Url}]
});

Package Sidebar

Install

npm i mongoose-type-url

Weekly Downloads

526

Version

2.1.0

License

MIT

Unpacked Size

6.06 kB

Total Files

5

Last publish

Collaborators

  • konsumer