Next attempt to define API.
Still it is a bit clumsy, see example use in JsonSchemaValidatorTest, e.g.
@Test
public void testValidationOfSimpleInValidPhenopacket() {
PhenopacketValidatorOld validator = FACTORY.getValidatorForType(ValidatorInfo.generic()).get();
String invalidPhenopacketJson = "{\"disney\" : \"donald\"}";
List<? extends ValidationItem> errors = validator.validate(invalidPhenopacketJson);
assertEquals(3, errors.size());
ValidationItem error = errors.get(0);
// JsonError.CATEGORY is "JSON"
assertEquals(JsonError.CATEGORY, error.errorType().category());
assertEquals(JsonError.REQUIRED, error.errorType().subcategory());
assertEquals("$.id: is missing but it is required", error.errorType().message());
error = errors.get(1);
assertEquals(JsonError.CATEGORY, error.errorType().category());
assertEquals(JsonError.REQUIRED, error.errorType().subcategory());
assertEquals("$.metaData: is missing but it is required", error.errorType().message());
error = errors.get(2);
assertEquals(JsonError.CATEGORY, error.errorType().category());
assertEquals(JsonError.ADDITIONAL_PROPERTIES, error.errorType().subcategory());
assertEquals("$.disney: is not defined in the schema and the schema does not allow additional properties",
error.errorType().message());
}
Next attempt to define API. Still it is a bit clumsy, see example use in
JsonSchemaValidatorTest
, e.g.