Enforce non-empty document in Monaco Editor
up vote
0
down vote
favorite
Using the monaco editor playground (https://microsoft.github.io/monaco-editor/playground.html#extending-language-services-configure-json-defaults) it would seem that a completely empty document passes JSON schema validation.
I would think that the empty document should be interpretted as the null type and therefore require {type: "null"}
in order to pass validation. Other libraries such as ajv (https://github.com/epoberezkin/ajv) interpret emptiness (undefined
) as invalid for {type: "object"}
Is there a way to do this out of the box with monaco editor and json schema?
jsonschema monaco-editor
New contributor
add a comment |
up vote
0
down vote
favorite
Using the monaco editor playground (https://microsoft.github.io/monaco-editor/playground.html#extending-language-services-configure-json-defaults) it would seem that a completely empty document passes JSON schema validation.
I would think that the empty document should be interpretted as the null type and therefore require {type: "null"}
in order to pass validation. Other libraries such as ajv (https://github.com/epoberezkin/ajv) interpret emptiness (undefined
) as invalid for {type: "object"}
Is there a way to do this out of the box with monaco editor and json schema?
jsonschema monaco-editor
New contributor
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
Using the monaco editor playground (https://microsoft.github.io/monaco-editor/playground.html#extending-language-services-configure-json-defaults) it would seem that a completely empty document passes JSON schema validation.
I would think that the empty document should be interpretted as the null type and therefore require {type: "null"}
in order to pass validation. Other libraries such as ajv (https://github.com/epoberezkin/ajv) interpret emptiness (undefined
) as invalid for {type: "object"}
Is there a way to do this out of the box with monaco editor and json schema?
jsonschema monaco-editor
New contributor
Using the monaco editor playground (https://microsoft.github.io/monaco-editor/playground.html#extending-language-services-configure-json-defaults) it would seem that a completely empty document passes JSON schema validation.
I would think that the empty document should be interpretted as the null type and therefore require {type: "null"}
in order to pass validation. Other libraries such as ajv (https://github.com/epoberezkin/ajv) interpret emptiness (undefined
) as invalid for {type: "object"}
Is there a way to do this out of the box with monaco editor and json schema?
jsonschema monaco-editor
jsonschema monaco-editor
New contributor
New contributor
edited Nov 7 at 20:20
New contributor
asked Nov 6 at 17:15
Michael Heavenor
32
32
New contributor
New contributor
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
up vote
0
down vote
accepted
The JSON syntax says that a JSON document starts with a value. An empty document is not the same as having "null" as content. Given that JSON schema defines constraints on the JSON input, an empty document, where nothing is here to apply the constraints, would be valid.
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
accepted
The JSON syntax says that a JSON document starts with a value. An empty document is not the same as having "null" as content. Given that JSON schema defines constraints on the JSON input, an empty document, where nothing is here to apply the constraints, would be valid.
add a comment |
up vote
0
down vote
accepted
The JSON syntax says that a JSON document starts with a value. An empty document is not the same as having "null" as content. Given that JSON schema defines constraints on the JSON input, an empty document, where nothing is here to apply the constraints, would be valid.
add a comment |
up vote
0
down vote
accepted
up vote
0
down vote
accepted
The JSON syntax says that a JSON document starts with a value. An empty document is not the same as having "null" as content. Given that JSON schema defines constraints on the JSON input, an empty document, where nothing is here to apply the constraints, would be valid.
The JSON syntax says that a JSON document starts with a value. An empty document is not the same as having "null" as content. Given that JSON schema defines constraints on the JSON input, an empty document, where nothing is here to apply the constraints, would be valid.
answered Nov 8 at 9:22
Clemens
746417
746417
add a comment |
add a comment |
Michael Heavenor is a new contributor. Be nice, and check out our Code of Conduct.
Michael Heavenor is a new contributor. Be nice, and check out our Code of Conduct.
Michael Heavenor is a new contributor. Be nice, and check out our Code of Conduct.
Michael Heavenor is a new contributor. Be nice, and check out our Code of Conduct.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53176812%2fenforce-non-empty-document-in-monaco-editor%23new-answer', 'question_page');
}
);
Post as a guest
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password