Skip to content
Snippets Groups Projects
Commit 97f48f12 authored by Hermann's avatar Hermann
Browse files

handle nullable fields in validation

parent 05cec218
No related branches found
No related tags found
No related merge requests found
...@@ -63,6 +63,14 @@ export default class EditView extends ItemView { ...@@ -63,6 +63,14 @@ export default class EditView extends ItemView {
if (objectSchema.properties[property].format === 'objectid') { if (objectSchema.properties[property].format === 'objectid') {
delete objectSchema.properties[property]; delete objectSchema.properties[property];
} }
// translate nullable field from OpenAPI specification to
// possible type null in jsonschema
if (objectSchema.properties[property].nullable) {
objectSchema.properties[property].type = [
'null',
objectSchema.properties[property].type,
];
}
}); });
// delete objectSchema.properties['_id']; // delete objectSchema.properties['_id'];
console.log(this.ajv.addSchema(objectSchema, 'schema')); console.log(this.ajv.addSchema(objectSchema, 'schema'));
...@@ -152,8 +160,8 @@ export default class EditView extends ItemView { ...@@ -152,8 +160,8 @@ export default class EditView extends ItemView {
return m(numInput, this.bind(field)); return m(numInput, this.bind(field));
} else if (field.type === 'checkbox') { } else if (field.type === 'checkbox') {
field.checked = this.data[key] || false; field.checked = this.data[key] || false;
field.onChange = (state) => { field.onChange = ({ checked }) => {
this.data[key] = state.checked; this.data[key] = checked;
}; };
delete field.type; delete field.type;
return m(Checkbox, field); return m(Checkbox, field);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment