Feature request: support `prefixItems`
counter2015 opened this issue · 1 comments
counter2015 commented
schema file
{
"type": "array",
"prefixItems": [
{
"type": "number"
},
{
"type": "string"
},
{
"enum": [
"Street",
"Avenue",
"Boulevard"
]
},
{
"enum": [
"NW",
"NE",
"SW",
"SE"
]
}
]
}
code
import org.everit.json.schema.loader.SchemaLoader;
import org.json.JSONArray;
import org.json.JSONObject;
import org.json.JSONTokener;
import java.io.IOException;
public class Feature {
static void check() {
try (var inputStream = Feature.class.getResourceAsStream("schema.json")) {
var rawSchema = new JSONObject(new JSONTokener(inputStream));
var schema = SchemaLoader.builder().schemaJson(rawSchema).draftV7Support().build().load().build();
schema.validate(new JSONArray("[24, \"Sussex\", \"Drive\"]\n"));
} catch (IOException e) {
throw new RuntimeException(e);
}
}
public static void main(String[] args) {
check();
}
}
it should failed check since “Drive” is not one of the acceptable street types:
erosb commented
Hello @counter2015 , I released a new validator which supports json schema draft2020-12, including the "prefixItems"
keyword.