I think that it was easy question, but I am puzzled. How Can I add minimum value to mongoose > 0?
var customer = new Schema({
cash: {
type: Number,
minimum: 0
}
});
this code allow 0 value, but I want to do > 0
I know, I can do this
var customer = new Schema({
cash: {
type: Number,
minimum: 0
},
validate: {
validator: function(value) {
return value > 0;
},
message: 'cash need to be > 0'
},
});
*cash is float, and can be very small
But it's too long, Is there an easier way?
minimum: 0.00000001
, but forNumber
types,min
andmax
are the only two options, and they work the way they work ("less/greater than, or equal"). Anything else, you need to implement yourself. – Ivetteivetts