@wmfs/j2119
Advanced tools
Comparing version 1.6.1 to 1.6.2
@@ -108,9 +108,10 @@ const oxford = require('./oxford') | ||
} | ||
} else { | ||
const anyOrObjectOrArray = !type || type === TYPES.object || type === TYPES.array | ||
// object field without a defined child role | ||
if (fieldName && !childType && anyOrObjectOrArray && (modal !== 'MUST NOT')) { | ||
this.roles.addGrandchildRole(role, fieldName, fieldName) | ||
this.allowedFields.setAny(fieldName) | ||
} | ||
} | ||
// object field without a defined child role | ||
if (fieldName && !childType && !type && (modal !== 'MUST NOT')) { | ||
this.roles.addGrandchildRole(role, fieldName, fieldName) | ||
this.allowedFields.setAny(fieldName) | ||
} | ||
} // assignConstraints | ||
@@ -117,0 +118,0 @@ |
{ | ||
"name": "@wmfs/j2119", | ||
"version": "1.6.1", | ||
"version": "1.6.2", | ||
"description": "A general-purpose validator generator that uses RFC2119-style assertions as input.", | ||
@@ -5,0 +5,0 @@ "author": "West Midlands Fire Service", |
@@ -124,2 +124,3 @@ /* eslint-env mocha */ | ||
const EXTENSION = require.resolve('./fixtures/TymlyExtension.j2119') | ||
const ALTERNAEXTENSION = require.resolve('./fixtures/AlternaTymlyExtension.j2119') | ||
const BAD = require.resolve('./fixtures/Bad.j2119') | ||
@@ -169,15 +170,39 @@ | ||
it('load an extension', () => { | ||
describe('load an Tymly extension', () => { | ||
const v = validator(SCHEMA, EXTENSION) | ||
const p = v.validate(STATE_MACHINE) | ||
expect(p.length).to.eql(2) // missing extensions! | ||
it('missing extension elements', () => { | ||
const p = v.validate(STATE_MACHINE) | ||
expect(p.length).to.eql(2) // missing extensions! | ||
}) | ||
const np = v.validate(STATE_MACHINE_WITH_RESOURCE_CONFIG_OBJECT) | ||
expect(np.length).to.eql(0) | ||
it('resource config object is valid', () => { | ||
const np = v.validate(STATE_MACHINE_WITH_RESOURCE_CONFIG_OBJECT) | ||
expect(np.length).to.eql(0) | ||
}) | ||
const nnp = v.validate(STATE_MACHINE_WITH_RESOURCE_CONFIG_ARRAY) | ||
expect(nnp.length).to.eql(0) | ||
it('resource config array is not valid', () => { | ||
const nnp = v.validate(STATE_MACHINE_WITH_RESOURCE_CONFIG_ARRAY) | ||
expect(nnp.length).to.eql(1) | ||
}) | ||
}) | ||
describe('load an AlternaTymly extension', () => { | ||
const v = validator(SCHEMA, ALTERNAEXTENSION) | ||
it('missing extension elements', () => { | ||
const p = v.validate(STATE_MACHINE) | ||
expect(p.length).to.eql(2) // missing extensions! | ||
}) | ||
it('resource config object is valid', () => { | ||
const np = v.validate(STATE_MACHINE_WITH_RESOURCE_CONFIG_OBJECT) | ||
expect(np.length).to.eql(1) | ||
}) | ||
it('resource config array is not valid', () => { | ||
const nnp = v.validate(STATE_MACHINE_WITH_RESOURCE_CONFIG_ARRAY) | ||
expect(nnp.length).to.eql(0) | ||
}) | ||
}) | ||
it('report when unable to load', () => { | ||
@@ -184,0 +209,0 @@ expect(() => validator(SCHEMA, 'chuckle-brothers')).to.throw('no such file') |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
138617
41
2884