本文整理汇总了Java中com.networknt.schema.ValidationMessage类的典型用法代码示例。如果您正苦于以下问题:Java ValidationMessage类的具体用法?Java ValidationMessage怎么用?Java ValidationMessage使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ValidationMessage类属于com.networknt.schema包,在下文中一共展示了ValidationMessage类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: doValidate
import com.networknt.schema.ValidationMessage; //导入依赖的package包/类
private static void doValidate(final Map<String, JsonNode> schemas,
final int i)
{
String name;
JsonNode value;
Set<ValidationMessage> errors;
for (final Map.Entry<String, JsonNode> entry: schemas.entrySet()) {
name = entry.getKey();
value = entry.getValue();
errors = SCHEMA.validate(value);
if (errors.size() > 0) {
System.err.println("ERROR: schema " + name + " did not "
+ "validate (iteration " + i + ')');
System.err.println(errors);
System.exit(1);
}
}
}
开发者ID:networknt,项目名称:json-schema-validator-perftest,代码行数:19,代码来源:NetworkntPerf.java
示例2: handleErrorMessages
import com.networknt.schema.ValidationMessage; //导入依赖的package包/类
private void handleErrorMessages(
HttpServletRequest request,
HttpServletResponse response,
Set<ValidationMessage> validationMessages)
throws IOException {
StringBuilder validationResult = new StringBuilder();
for (ValidationMessage s : validationMessages) {
String message = s.getMessage();
validationResult.append(message).append(", ");
}
log.trace("Response body is : " + validationResult);
log.trace(request.getHeader("Accept"));
if (request.getHeader("Accept").equalsIgnoreCase("application/json")
|| request.getHeader("Accept").equalsIgnoreCase("application/octet-stream")) {
response.setContentLength(validationResult.length());
response.setContentType(MediaType.APPLICATION_JSON_VALUE);
response.sendError(
HttpServletResponse.SC_BAD_REQUEST, validationResult.toString().replace("$.", " "));
}
}
开发者ID:openbaton,项目名称:NFVO,代码行数:22,代码来源:SchemaValidatorInterceptor.java
示例3: isValid
import com.networknt.schema.ValidationMessage; //导入依赖的package包/类
@Override
public RequestParameter isValid(String value) throws ValidationException {
try {
JsonNode node;
if (value == null)
throw ValidationException.ValidationExceptionFactory.generateNotParsableJsonBodyException("Json should not be null");
else if (value.length() == 0)
node = JsonNodeFactory.instance.textNode("");
else
node = Json.mapper.readTree(value);
Set<ValidationMessage> errors = schema.validate(node);
if (errors.size() == 0) {
return RequestParameter.create(new JsonObject(value));
} else {
throw ValidationException.ValidationExceptionFactory.generateInvalidJsonBodyException(errors.iterator().next().toString());
}
} catch (IOException e) {
throw ValidationException.ValidationExceptionFactory.generateNotParsableJsonBodyException(e.getMessage());
}
}
开发者ID:vert-x3,项目名称:vertx-web,代码行数:22,代码来源:JsonTypeValidator.java
示例4: matchesSafely
import com.networknt.schema.ValidationMessage; //导入依赖的package包/类
@Override
protected boolean matchesSafely(String item, Description mismatchDescription) {
ObjectMapper objectMapper = new ObjectMapper();
JsonNode jsonNode = getJsonNode(item, objectMapper);
List<String> validationMessages = schema.validate(jsonNode)
.stream()
.map(ValidationMessage::getMessage)
.collect(toList());
mismatchDescription.appendValueList("schema validation failed with the following errors: \n - ", "\n - ", "", validationMessages);
return validationMessages.isEmpty();
}
开发者ID:tyro,项目名称:pact-spring-mvc,代码行数:15,代码来源:JsonSchemaMatcher.java
示例5: validateSchema
import com.networknt.schema.ValidationMessage; //导入依赖的package包/类
public static Set<ValidationMessage> validateSchema(String jsonClassSchema, String jsonInstance)
throws BadRequestException, IOException {
JsonSchema finalSchema = getJsonSchemaFromStringContent(jsonClassSchema);
JsonNode node = getJsonNodeFromStringContent(jsonInstance);
return finalSchema.validate(node);
}
开发者ID:openbaton,项目名称:NFVO,代码行数:9,代码来源:SchemaValidator.java
注:本文中的com.networknt.schema.ValidationMessage类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论