Skip to content

Commit 404f6d1

Browse files
Adds support for additional properties (#151)
1 parent a56d4bc commit 404f6d1

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

src/formBuilder/FormBuilder.test.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,4 +263,31 @@ describe('FormBuilder', () => {
263263
.map((error) => error.text());
264264
expect(errors).toEqual([]);
265265
});
266+
267+
it('validates additionalProperties as a valid property', () => {
268+
const jsonSchema = {
269+
$schema: `http://json-schema.org/draft-07/schema#`,
270+
properties: {},
271+
required: [],
272+
additionalProperties: false,
273+
};
274+
275+
const props = {
276+
schema: JSON.stringify(jsonSchema),
277+
uiSchema: '{}',
278+
onChange: jest.fn(() => {}),
279+
mods: {},
280+
className: 'my-form-builder',
281+
};
282+
283+
const div = document.createElement('div');
284+
document.body.appendChild(div);
285+
const wrapper = mount(<FormBuilder {...props} />, { attachTo: div });
286+
const errors = wrapper
287+
.find('.alert-warning')
288+
.first()
289+
.find('li')
290+
.map((error) => error.text());
291+
expect(errors).toEqual([]);
292+
});
266293
});

src/formBuilder/utils.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ const supportedPropertyParameters = new Set([
146146
'$id',
147147
'$schema',
148148
'meta',
149+
'additionalProperties',
149150
]);
150151

151152
const supportedUiParameters = new Set([

0 commit comments

Comments
 (0)