Class ArrayTypeValidator

java.lang.Object
org.forgerock.json.schema.validator.validators.Validator
org.forgerock.json.schema.validator.validators.ArrayTypeValidator
All Implemented Interfaces:
SimpleValidator<Object>

public class ArrayTypeValidator extends Validator
ArrayTypeValidator applies all the constraints of a array type.

Sample JSON Schema:

{ "type" : "array", "required" : true, "uniqueItems" : "true", "minItems" : 2, "maxItems" : 3, "additionalItems" : { "type" : "string", "enum" : [ "test1", "test2", "test3" ] }, "items" : { "type" : "string" } }
See Also:
  • Constructor Details

    • ArrayTypeValidator

      public ArrayTypeValidator(Map<String,Object> schema, List<String> jsonPointer)
      Default ctor.
      Parameters:
      schema - the schema holding the reference to this validator
      jsonPointer - the JSON pointer locating where this validator was defined in the schema.
  • Method Details

    • validate

      public void validate(Object node, JsonPointer at, ErrorHandler handler)
      Validates the node value against the embedded schema object.

      The selected error handler defines the behaviour of the validator. The FailFastErrorHandler throws exception at firs violation. Other customised ErrorHandler can collect all exceptions and after the validation the examination of the handler contains the final result.

      Parameters:
      node - value to validate
      at - JSONPath of the node. null means it's the root node
      handler - customised error handler like FailFastErrorHandler
    • collectAllValidators

      protected void collectAllValidators(Collection<Validator> results)
      Collects all the sub-validators held in this validator and aggregates them in the passed in Collection.
      Overrides:
      collectAllValidators in class Validator
      Parameters:
      results - where collected validators are aggregated