Open satra opened 3 years ago
FWIW, it seems that it doesn't show because there is no "type": "string",
before. But it seems to be not required, e.g. valid in https://www.jsonschemavalidator.net/s/On8R53GD . But if added, then I think anyOf
is just completely ignored for validation, since "invalid" in aforementioned in validator would show up valid in @satra's codepen
FWIW: related https://github.com/koumoul-dev/vuetify-jsonschema-form/issues/241
I think there are several changes required to manage properly this schema, please correct me if I am wrong:
I think that the easiest way to implement the last 2 points would be to finally review and document this ajv integration pull request that I keep forgetting about.
Is loading the full ajv library client-side something that would be possible for you, or would you prefer that vjsf implement some more complex validation by itself ? Taking into consideration the fact that there will always be limitations to what can reasonably be implemented in vjsf.
@albanm - the challenge is that format
support would need to be added, perhaps through a config option. in general the JSON schema spec says format
does not have to be supported by any client. so what vjsf is doing right now actually is schema compliant.
in the context of anyOf
complex objects, vjsf does show a choice list to select them. perhaps the same thing could be done for allOf/anyOf/oneOf for combinations of things. but indeed this is more complicated.
if ajv addresses this, that sounds great.
Showing different inputs would be in the scope of vjsf, but I don't think that would be the proper answer here. Anyway I don't think it would be doable as there would not be a clue in the model about what input needs to be displayed (no const property as vjsf uses in anyOf of complex objects).
It seems to me that the proper response here is simply to interpret the anyOf as a combined validation rule for a simple string input. This would be perfectly supported by the ajv integration I think, as well as checking default formats and adding custom formats.
I will work on testing/merging/documenting the ajv integration pull request.
I worked on ajv integration (not released yet). This example is very similar to your use case, you can check it out.
since this asked me to file a report, i'm filling it here:
overall it looks good, just wanted to make sure what makes vjsf consider it valid while jsonschema does not.
The link I gave you was working fine for me, are you simply opening the documentation in a browser or is there another context that I miss ? If you are simply opening the documentation can you tell me what browser you are using and whether there are some error messages in the console ?
Fyi the link was to the documentation of the master branch, this has been released since then and is available on latest.
i'm using the brave browser and the released link (same message):
it does look like that the ajv extension is detecting the invalid section. just that vjsf is not considering it invalid.
The ajv message you get is provided by the ajv instance that is run by the documentation site outside of vjsf to check for discrepancies. The recent evolution was to use an ajv instance internally to vjsf, this is different. The expected render is this:
No error message in your browser's console ?
when a property itself takes anyOf of two different types, the field is ignored and not displayed.
see the property identifier in this example here: https://codepen.io/satra-the-reactor/pen/PomjgYK?editors=1010
there are no errors in the console.