use of com.github.fge.jsonschema.main.JsonValidator in project metron by apache.
the class AbstractParserConfigTest method validateJsonData.
protected boolean validateJsonData(final String jsonSchema, final String jsonData) throws IOException, ProcessingException {
final JsonNode d = JsonLoader.fromString(jsonData);
final JsonNode s = JsonLoader.fromString(jsonSchema);
final JsonSchemaFactory factory = JsonSchemaFactory.byDefault();
JsonValidator v = factory.getValidator();
ProcessingReport report = v.validate(s, d);
return report.toString().contains("success");
}
use of com.github.fge.jsonschema.main.JsonValidator in project metron by apache.
the class CEFParserTest method validateJsonData.
protected boolean validateJsonData(final String jsonSchema, final String jsonData) throws Exception {
final JsonNode d = JsonLoader.fromString(jsonData);
final JsonNode s = JsonLoader.fromString(jsonSchema);
final JsonSchemaFactory factory = JsonSchemaFactory.byDefault();
JsonValidator v = factory.getValidator();
ProcessingReport report = v.validate(s, d);
return report.toString().contains("success");
}
use of com.github.fge.jsonschema.main.JsonValidator in project thingsboard by thingsboard.
the class BaseComponentDescriptorService method validate.
@Override
public boolean validate(ComponentDescriptor component, JsonNode configuration) {
JsonValidator validator = JsonSchemaFactory.byDefault().getValidator();
try {
if (!component.getConfigurationDescriptor().has("schema")) {
throw new DataValidationException("Configuration descriptor doesn't contain schema property!");
}
JsonNode configurationSchema = component.getConfigurationDescriptor().get("schema");
ProcessingReport report = validator.validate(configurationSchema, configuration);
return report.isSuccess();
} catch (ProcessingException e) {
throw new IncorrectParameterException(e.getMessage(), e);
}
}
Aggregations