implementation
Signed-off-by: Yaapa Hage <hage.yaapa@in.ibm.com>
This commit is contained in:
parent
d6a28f6aa1
commit
92286e14c3
|
@ -355,6 +355,11 @@ ModelBuilder.prototype.define = function defineClass(className, properties, sett
|
|||
forceId = false;
|
||||
}
|
||||
|
||||
// Make id value mandatory if it is not autogenerated
|
||||
if (!idProp.generated) {
|
||||
ModelClass.validatesPresenceOf(idName);
|
||||
}
|
||||
|
||||
if (forceId) {
|
||||
ModelClass.validatesAbsenceOf(idName, {if: 'isNewRecord'});
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@ const uid = require('./helpers/uid-generator');
|
|||
let ds;
|
||||
const ValidationError = require('..').ValidationError;
|
||||
|
||||
describe.only('id property', function() {
|
||||
describe('id property', function() {
|
||||
before(function() {
|
||||
ds = getSchema();
|
||||
});
|
||||
|
@ -74,7 +74,7 @@ describe.only('id property', function() {
|
|||
|
||||
// If id is not autogenerated, forceId is not applicable and a value must be specified
|
||||
it('should require id value', async () => {
|
||||
await IdCheckC.create({name: 'Pablo'}).should.be.rejected();
|
||||
await IdCheckC.create({name: 'Pablo'}).should.be.rejectedWith({statusCode: 422});
|
||||
});
|
||||
|
||||
// If id is not autogenerated, forceId is not applicable and a value can be specified
|
||||
|
@ -96,7 +96,7 @@ describe.only('id property', function() {
|
|||
|
||||
// If id is not autogenerated, forceId is not applicable and a value must be specified
|
||||
it('should require id value', async () => {
|
||||
await IdCheckD.create({name: 'Pablo'}).should.be.rejected();
|
||||
await IdCheckD.create({name: 'Pablo'}).should.be.rejectedWith({statusCode: 422});
|
||||
});
|
||||
|
||||
// If id is not autogenerated, forceId is not applicable and a value can be specified
|
||||
|
|
Loading…
Reference in New Issue