Package org.eel.kitchen.jsonschema.syntax

Schema syntax validation package

See: Description

Package org.eel.kitchen.jsonschema.syntax Description

Schema syntax validation package

The main class in this package is SyntaxValidator.

Syntax validation has a critically important role in the validation process. An invalid schema will always fail to invalidate a JSON instance.

For this implementation in particular, it also helps to ensure that the KeywordValidator associated with the schema keyword does not need to preoccupy about its arguments being well-formed -- they will be since the syntax validator has verified that they are.

Unlike keyword validators, syntax validators are not built by reflection. It is therefore your responsibility to instantiate it and only then register it.

Here is an example code for a hypothetic foo keyword which must have a string as an argument, and this string must be at least 5 characters long:

  public final class SyntaxCheckerImpl
      implements SyntaxChecker
  {
      @Override
      public void checkSyntax(final List<String> messages,
          final JsonNode schema)
      {
          final JsonNode node = schema.get("foo");
          if (!node.isTextual()) {
              messages.add("field is not a string");
              return;
          }

          if (node.textValue().length() < 5)
              messages.add("field has insufficient length");
      }
  }
 

For more information, see SyntaxChecker.

Copyright © 2012. All Rights Reserved.