Merge pull request #267 from fabien/fix/tiny
Fix error messages, should be lowercase
This commit is contained in:
commit
1440b800da
|
@ -210,6 +210,7 @@ ModelDefinition.prototype.build = function (forceRebuild) {
|
||||||
this.properties = null;
|
this.properties = null;
|
||||||
this.relations = [];
|
this.relations = [];
|
||||||
this._ids = null;
|
this._ids = null;
|
||||||
|
this.json = null;
|
||||||
}
|
}
|
||||||
if (this.properties) {
|
if (this.properties) {
|
||||||
return this.properties;
|
return this.properties;
|
||||||
|
|
|
@ -1853,7 +1853,7 @@ RelationDefinition.embedsMany = function embedsMany(modelFrom, modelTo, params)
|
||||||
return ids.indexOf(id) === pos;
|
return ids.indexOf(id) === pos;
|
||||||
});
|
});
|
||||||
if (ids.length !== uniqueIds.length) {
|
if (ids.length !== uniqueIds.length) {
|
||||||
this.errors.add(propertyName, 'Contains duplicate `' + idName + '`', 'uniqueness');
|
this.errors.add(propertyName, 'contains duplicate `' + idName + '`', 'uniqueness');
|
||||||
err(false);
|
err(false);
|
||||||
}
|
}
|
||||||
}, { code: 'uniqueness' })
|
}, { code: 'uniqueness' })
|
||||||
|
@ -1877,7 +1877,7 @@ RelationDefinition.embedsMany = function embedsMany(modelFrom, modelTo, params)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
hasErrors = true;
|
hasErrors = true;
|
||||||
self.errors.add(propertyName, 'Contains invalid item', 'invalid');
|
self.errors.add(propertyName, 'contains invalid item', 'invalid');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if (hasErrors) err(false);
|
if (hasErrors) err(false);
|
||||||
|
@ -2325,7 +2325,7 @@ RelationDefinition.referencesMany = function referencesMany(modelFrom, modelTo,
|
||||||
return ids.indexOf(id) === pos;
|
return ids.indexOf(id) === pos;
|
||||||
});
|
});
|
||||||
if (ids.length !== uniqueIds.length) {
|
if (ids.length !== uniqueIds.length) {
|
||||||
var msg = 'Contains duplicate `' + modelTo.modelName + '` instance';
|
var msg = 'contains duplicate `' + modelTo.modelName + '` instance';
|
||||||
this.errors.add(relationName, msg, 'uniqueness');
|
this.errors.add(relationName, msg, 'uniqueness');
|
||||||
err(false);
|
err(false);
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,6 +55,8 @@ describe('ModelDefinition class', function () {
|
||||||
});
|
});
|
||||||
|
|
||||||
User.build();
|
User.build();
|
||||||
|
|
||||||
|
var json = User.toJSON();
|
||||||
|
|
||||||
User.defineProperty("id", {type: "number", id: true});
|
User.defineProperty("id", {type: "number", id: true});
|
||||||
assert.equal(User.properties.name.type, String);
|
assert.equal(User.properties.name.type, String);
|
||||||
|
@ -62,8 +64,12 @@ describe('ModelDefinition class', function () {
|
||||||
assert.equal(User.properties.approved.type, Boolean);
|
assert.equal(User.properties.approved.type, Boolean);
|
||||||
assert.equal(User.properties.joinedAt.type, Date);
|
assert.equal(User.properties.joinedAt.type, Date);
|
||||||
assert.equal(User.properties.age.type, Number);
|
assert.equal(User.properties.age.type, Number);
|
||||||
|
|
||||||
assert.equal(User.properties.id.type, Number);
|
assert.equal(User.properties.id.type, Number);
|
||||||
|
|
||||||
|
json = User.toJSON();
|
||||||
|
assert.deepEqual(json.properties.id, {type: 'Number', id: true});
|
||||||
|
|
||||||
done();
|
done();
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
|
@ -2411,7 +2411,7 @@ describe('relations', function () {
|
||||||
err.name.should.equal('ValidationError');
|
err.name.should.equal('ValidationError');
|
||||||
err.details.codes.jobs.should.eql(['uniqueness']);
|
err.details.codes.jobs.should.eql(['uniqueness']);
|
||||||
var expected = 'The `Category` instance is not valid. ';
|
var expected = 'The `Category` instance is not valid. ';
|
||||||
expected += 'Details: `jobs` Contains duplicate `Job` instance.';
|
expected += 'Details: `jobs` contains duplicate `Job` instance.';
|
||||||
err.message.should.equal(expected);
|
err.message.should.equal(expected);
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue