@thxmike/mongoose-url-type
TypeScript icon, indicating that this package has built-in type declarations

1.0.14 • 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 @thxmike/mongoose-url-type

Weekly Downloads

9

Version

1.0.14

License

MIT

Unpacked Size

11.2 kB

Total Files

12

Last publish

Collaborators

  • thxmike