Class UnionTypeValidator
- java.lang.Object
-
- org.forgerock.json.schema.validator.validators.Validator
-
- org.forgerock.json.schema.validator.validators.UnionTypeValidator
-
- All Implemented Interfaces:
SimpleValidator<Object>
public class UnionTypeValidator extends Validator
Union Types An array of two or more simple validators definitions. Each item in the array MUST be a simple validators definition or a schema. The instance value is valid if it is of the same validators as one of the simple validators definitions, or valid by one of the schemas, in the array.For example, a schema that defines if an instance can be a string or a number would be:
{"type":["string","number"]}
- See Also:
- type
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
validate(Object node, JsonPointer at, ErrorHandler handler)
Validates thenode
value against the embedded schema object.-
Methods inherited from class org.forgerock.json.schema.validator.validators.Validator
collectAllValidators, collectAllValidators, collectAllValidators, getJsonPointer, getPath, isRequired, newList, resolveSchemaReferences, toString
-
-
-
-
Method Detail
-
validate
public void validate(Object node, JsonPointer at, ErrorHandler handler) throws SchemaException
Validates thenode
value against the embedded schema object.The selected error handler defines the behaviour of the validator. The
FailFastErrorHandler
throws exception at firs violation. Other customisedErrorHandler
can collect all exceptions and after the validation the examination of thehandler
contains the final result.- Parameters:
node
- value to validateat
- JSONPath of the node. null means it's the root nodehandler
- customised error handler likeFailFastErrorHandler
- Throws:
SchemaException
- when thenode
violates with the schema
-
-