@Override public void validate(final ProcessingReport report, final MessageBundle bundle, final FullData data) throws ProcessingException { final String input = data.getInstance().getNode().textValue(); if (!MACADDR.matcher(input).matches()) report.error(newMsg(data, bundle, "err.format.macAddr.invalid") .putArgument("value", input)); } }
@Override public void validate(final Processor<FullData, FullData> processor, final ProcessingReport report, final MessageBundle bundle, final FullData data) throws ProcessingException { final Set<String> set = Sets.newLinkedHashSet(required); set.removeAll(Sets.newHashSet(data.getInstance().getNode() .fieldNames())); if (!set.isEmpty()) report.error(newMsg(data, bundle, "err.common.object.missingMembers") .put("required", required) .putArgument("missing", toArrayNode(set))); }
@Override public void validate(final Processor<FullData, FullData> processor, final ProcessingReport report, final MessageBundle bundle, final FullData data) throws ProcessingException { final Set<String> set = Sets.newLinkedHashSet(required); set.removeAll(Sets.newHashSet(data.getInstance().getNode() .fieldNames())); if (!set.isEmpty()) report.error(newMsg(data, bundle, "err.common.object.missingMembers") .put("required", required) .putArgument("missing", toArrayNode(set))); }
@Override public void validate(final ProcessingReport report, final MessageBundle bundle, final FullData data) throws ProcessingException { final String value = data.getInstance().getNode().textValue(); try { UUID.fromString(value); } catch (IllegalArgumentException ignored) { report.error(newMsg(data, bundle, "invalidUUID") .put("input", value)); } } }
@Override public void validate(final ProcessingReport report, final MessageBundle bundle, final FullData data) throws ProcessingException { final String value = data.getInstance().getNode().textValue(); try { new InternetAddress(value, true); } catch (AddressException ignored) { report.error(newMsg(data, bundle, "err.format.invalidEmail") .putArgument("value", value)); } } }
@Override public void validate(final ProcessingReport report, final MessageBundle bundle, final FullData data) throws ProcessingException { final String value = data.getInstance().getNode().textValue(); try { new URI(value); } catch (URISyntaxException ignored) { report.error(newMsg(data, bundle, "err.format.invalidURI") .putArgument("value", value)); } } }
public SchemaContext(final FullData data) { schema = data.getSchema(); final JsonTree tree = data.getInstance(); instanceType = tree != null ? NodeType.getNodeType(tree.getNode()) : null; }
@Override public void validate(final Processor<FullData, FullData> processor, final ProcessingReport report, final MessageBundle bundle, final FullData data) throws ProcessingException { final int size = data.getInstance().getNode().size(); if (size > intValue) report.error(newMsg(data, bundle, "err.draftv4.maxProperties.tooManyMembers") .putArgument("found", size).putArgument("required", intValue)); } }
@Override public void validate(final ProcessingReport report, final MessageBundle bundle, final FullData data) throws ProcessingException { final String ipaddr = data.getInstance().getNode().textValue(); if (InetAddresses.isInetAddress(ipaddr) && InetAddresses .forString(ipaddr).getAddress().length == IPV4_LENGTH) return; report.error(newMsg(data, bundle, "err.format.invalidIPv4Address") .putArgument("value", ipaddr)); } }
@Override public void validate(final ProcessingReport report, final MessageBundle bundle, final FullData data) throws ProcessingException { final String value = data.getInstance().getNode().textValue(); if (!RhinoHelper.regexIsValid(value)) report.error(newMsg(data, bundle, "err.format.invalidRegex") .putArgument("value", value)); } }
@Override public void validate(final ProcessingReport report, final MessageBundle bundle, final FullData data) throws ProcessingException { final String value = data.getInstance().getNode().textValue(); try { new URITemplate(value); } catch (URITemplateParseException ignored) { report.error(newMsg(data, bundle, "err.format.uriTemplate.invalid") .putArgument("value", value)); } } }
@Override public void validate(final Processor<FullData, FullData> processor, final ProcessingReport report, final MessageBundle bundle, final FullData data) throws ProcessingException { if (additionalOK) return; final int size = data.getInstance().getNode().size(); if (size > itemsSize) report.error(newMsg(data, bundle, "err.common.additionalItems.notAllowed") .putArgument("allowed", itemsSize).putArgument("found", size)); }
@Override public void validate(final Processor<FullData, FullData> processor, final ProcessingReport report, final MessageBundle bundle, final FullData data) throws ProcessingException { final int size = data.getInstance().getNode().size(); if (size < intValue) report.error(newMsg(data, bundle, "err.common.minItems.arrayTooShort") .putArgument(keyword, intValue).putArgument("found", size)); } }
@Override public void validate(final Processor<FullData, FullData> processor, final ProcessingReport report, final MessageBundle bundle, final FullData data) throws ProcessingException { final int size = data.getInstance().getNode().size(); if (size < intValue) report.error(newMsg(data, bundle, "err.draftv4.minProperties.notEnoughMembers") .putArgument("found", size).putArgument("required", intValue)); } }
@Override public void validate(final Processor<FullData, FullData> processor, final ProcessingReport report, final MessageBundle bundle, final FullData data) throws ProcessingException { final int size = data.getInstance().getNode().size(); if (size > intValue) report.error(newMsg(data, bundle, "err.common.maxItems.arrayTooLarge") .putArgument(keyword, intValue).putArgument("found", size)); } }
@Override public void validate(final ProcessingReport report, final MessageBundle bundle, final FullData data) throws ProcessingException { final String value = data.getInstance().getNode().textValue(); try { InternetDomainName.from(value); } catch (IllegalArgumentException ignored) { report.error(newMsg(data, bundle, "err.format.invalidHostname") .putArgument("value", value)); } } }
@Override public void validate(final Processor<FullData, FullData> processor, final ProcessingReport report, final MessageBundle bundle, final FullData data) throws ProcessingException { final String regex = data.getSchema().getNode().get(keyword) .textValue(); final String value = data.getInstance().getNode().textValue(); if (!RhinoHelper.regMatch(regex, value)) report.error(newMsg(data, bundle, "err.common.pattern.noMatch") .putArgument("regex", regex).putArgument("string", value)); }
@Override public final void validate(final Processor<FullData, FullData> processor, final ProcessingReport report, final MessageBundle bundle, final FullData data) throws ProcessingException { final JsonNode instance = data.getInstance().getNode(); if (valueIsLong(instance) && isLong) validateLong(report, bundle, data); else validateDecimal(report, bundle, data); }
@Override public void validate(final Processor<FullData, FullData> processor, final ProcessingReport report, final MessageBundle bundle, final FullData data) throws ProcessingException { final NodeType type = NodeType.getNodeType(data.getInstance().getNode()); if (!types.contains(type)) report.error(newMsg(data, bundle, "err.common.typeNoMatch") .putArgument("found", type) .putArgument("expected", toArrayNode(types))); }
@Override public void validate(final Processor<FullData, FullData> processor, final ProcessingReport report, final MessageBundle bundle, final FullData data) throws ProcessingException { final JsonNode node = data.getInstance().getNode(); for (final JsonNode enumValue: values) if (EQUIVALENCE.equivalent(enumValue, node)) return; report.error(newMsg(data, bundle, "err.common.enum.notInEnum") .putArgument("value", node).putArgument(keyword, values)); }