Max Validator

API ReferenceSchemaMax Validator

Determines the maximum range of the number.

The tested value can be lower or equal maximum.

var schema = new Schema({
  age: {
    max: 200
  }
});

console.log(utils.catchError(schema.validate, schema, [{age: 201}])+'');
// "SchemaError: Maximum range of age is 200"

console.log(schema.validate({age: 'string'}));
// true

console.log(schema.validate({age: 200}));
// true

console.log(schema.validate({age: -5}));
// true

Source

results matching ""

    No results matching ""