Skip to content

Commit 5bbaf25

Browse files
committed
Fix #56: Add support for object's required properties
1 parent c384509 commit 5bbaf25

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

src/dataValidation.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,11 @@ export default function DataValidator(schema) {
163163
if (next_schema.hasOwnProperty('$ref'))
164164
next_schema = this.getRef(next_schema.$ref);
165165

166+
if (schema.hasOwnProperty('required') && Array.isArray(schema.required)) {
167+
if (schema.required.indexOf(key) > -1)
168+
next_schema['required'] = true;
169+
}
170+
166171
let next_type = normalizeKeyword(next_schema.type);
167172

168173
let next_validator = this.getValidator(next_type);

src/ui.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -395,6 +395,11 @@ export function getObjectFormRow(args) {
395395
if (schema_keys[key] === undefined)
396396
removable = true;
397397

398+
if (schema.hasOwnProperty('required') && Array.isArray(schema.required)) {
399+
if (schema.required.indexOf(key) > -1)
400+
schemaValue['required'] = true;
401+
}
402+
398403
let nextArgs = {
399404
data: value,
400405
schema: schemaValue,

0 commit comments

Comments
 (0)