You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The uri format in JaySchema is very generous in what it allows. In your example, invalid is a valid relative URI. (Imagine an HTML tag, <a href="pagename">, which is valid.)
This should probably be fixed, so the uri format expects an absolute URI – which I think is what you’re looking for. But it needs testing to ensure it doesn’t break stuff. In particular, in the Core/Validation Meta-Schema, the id property is specified to use the uri format. That needs special handling, for example, with this example in the JSON Schema documentation.
I don’t have time to study this right now, but I will keep the issue open. And of course, if someone else wants to do it, pull requests are welcome.
Hi @asafyish. As of version 0.3.0, JaySchema can do this for you using a custom format validator. If the built-in uri format isn’t to your liking you can now override it:
varjs=newJaySchema();// This overrides the built-in `uri` format; you could also use your own// format name (like `my-uri`).js.addFormat('uri',function(value){// Do your own URI validation here, and return null if the value is valid,// or, if the value is not valid, return a string describing the problem.});
This should throw an error, but it doesn't:
The text was updated successfully, but these errors were encountered: