@Test public void testInvalidArrayValue() { final List<RecordField> fields = new ArrayList<>(); fields.add(new RecordField("id", RecordFieldType.INT.getDataType())); fields.add(new RecordField("numbers", RecordFieldType.ARRAY.getArrayDataType(RecordFieldType.INT.getDataType()))); final RecordSchema schema = new SimpleRecordSchema(fields); final Map<String, Object> valueMap = new LinkedHashMap<>(); valueMap.put("id", 1); valueMap.put("numbers", new Object[] {1, "2", "3"}); Record record = new MapRecord(schema, valueMap, false, false); final SchemaValidationContext strictValidationContext = new SchemaValidationContext(schema, false, true); final SchemaValidationContext lenientValidationContext = new SchemaValidationContext(schema, false, false); StandardSchemaValidator validator = new StandardSchemaValidator(strictValidationContext); SchemaValidationResult result = validator.validate(record); assertFalse(result.isValid()); assertNotNull(result.getValidationErrors()); assertEquals(1, result.getValidationErrors().size()); final ValidationError validationError = result.getValidationErrors().iterator().next(); assertEquals("/numbers", validationError.getFieldName().get()); validator = new StandardSchemaValidator(lenientValidationContext); result = validator.validate(record); assertTrue(result.isValid()); assertNotNull(result.getValidationErrors()); assertTrue(result.getValidationErrors().isEmpty()); }
@Override public SchemaValidationResult validate(final Record record) { return validate(record, validationContext.getSchema(), ""); }
StandardSchemaValidator implements RecordSchemaValidator { @Override public SchemaValidationResult validate(final Record record) { return validate(record, validationContext.getSchema(), ""); } }
StandardSchemaValidator implements RecordSchemaValidator { @Override public SchemaValidationResult validate(final Record record) { return validate(record, validationContext.getSchema(), ""); } StandardSchemaValidator(final SchemaValidationContext validationContext); }
StandardSchemaValidator implements RecordSchemaValidator { @Override public SchemaValidationResult validate(final Record record) { return validate(record, validationContext.getSchema(), ""); } StandardSchemaValidator(final SchemaValidationContext validationContext); @Override SchemaValidationResult validate(final Record record); }
StandardSchemaValidator implements RecordSchemaValidator { @Override public SchemaValidationResult validate(final Record record) { return validate(record, validationContext.getSchema(), ""); } StandardSchemaValidator(final SchemaValidationContext validationContext); @Override SchemaValidationResult validate(final Record record);  }