Type "Number" may be causing interesting validation ripples. #1929

crispen-smith opened this Issue Feb 20, 2014 · 0 comments


None yet
1 participant

I'm not sure of the best way to document or replicate this issue, though I'm sure I should be able to.

I have the following model:

var mongoose = require('mongoose')
, uniqueValidator = require('mongoose-unique-validator')
, Schema = mongoose.Schema

var productSchema = new Schema({
name: {type: String, required: true, unique: true },
cost: {type: String, required: true},
summary: {type: String, required: true},
description: {type: String, required: true },
lead_image: {type: String, required: true }

module.exports = mongoose.model('product', productSchema);

When I have it configured this way and pass it valid data for price but empty strings for Summary or description, the save gives me expected errors. However, if I set the type of cost to Number then the subsequent fields don't fail as expected. I'm more than open to the idea that I'm doing something wrong, but I can't see where that would be.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment