Skip to content

kejiro/mongoose-validators-unique

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

mongoose-validators-unique

Unique validator for mongoose that supports conditions

Usage

Add the validator to a schema

var mongoose = require('mongoose');
var uniqueValidator = require('mongoose-validators-unique');

var schema = mongoose.Schema({});

schema.plugin(uniqueValidator);

Use the validator

var userSchema = mongoose.Schema({
    username: { type: String, required: true, unique: true },
    email: { type: String, unique: { conditions: { status: { $ne: 'archived' } } }, required: true },
    password: { type: String, required: true },
    status: { type: String }
});

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published