Validates a value against the minimum value provided
MinValueValidator is used by DataValidatorListener for validating data objects.
An attribute of a data model may define a max value in validation properties:
{
"name": "price",
"title": "Price",
"description": "The price of the product.",
"type": "Number",
"validation": {
"minValue":5
}
}
An operation tries to save a data object:
var obj = {
"price":2.5
"model": "FS2USB42",
"name": "USB 3.0 Adapter"
};
context.model("Product").save(obj).then(function() {
return done();
}).catch(function(err) {
return done(err);
});
and the result is:
{
"code": "EMINVAL",
"model": "Product",
"field": "price",
"message": "The value should be greater than or equal to 5."
}