scottwrobinson / camo

A class-based ES6 ODM for Mongo-like databases.
556 stars 80 forks source link

Validation message wrong when max value exceeded #84

Open AndyDBell opened 7 years ago

AndyDBell commented 7 years ago

Hi,

When a Document property max value is exceeded the returned error message is incorrect.
i.e. Value assigned to c.xxx is less than max, 180, got 275.16
instead of Value assigned to c.xxx is greater than max, 180, got 275.16

base-document.js line 201

if (isNumber(that._schema[key].max) && value > that._schema[key].max) {
                throw new ValidationError('Value assigned to ' + that.collectionName() + '.' + key +
                    ' is less than max, ' + that._schema[key].max + ', got ' + value);
            }

should be

if (isNumber(that._schema[key].max) && value > that._schema[key].max) {
                throw new ValidationError('Value assigned to ' + that.collectionName() + '.' + key +
                    ' is greater than max, ' + that._schema[key].max + ', got ' + value);
            }

Regards Andy