Class ObjectNodeValidator


  • public class ObjectNodeValidator
    extends Object
    This class is used to validate an ObjectNode against a list of AttributeDefinitions. It produces a report with the validation results.
    Author:
    Luca Frosini (ISTI - CNR)
    • Field Detail

      • logger

        protected static org.slf4j.Logger logger
        The logger.
      • nodeToValidate

        protected final org.gcube.com.fasterxml.jackson.databind.node.ObjectNode nodeToValidate
        The node to validate.
      • attributeDefinitions

        protected final List<? extends AttributeDefinition> attributeDefinitions
        The attribute definitions.
      • stopOnError

        protected final boolean stopOnError
        A flag indicating whether to stop on the first error.
      • validatorReport

        protected ValidatorReport validatorReport
        The validator report.
    • Constructor Detail

      • ObjectNodeValidator

        public ObjectNodeValidator​(org.gcube.com.fasterxml.jackson.databind.node.ObjectNode nodeToValidate,
                                   List<? extends AttributeDefinition> attributeDefinitions)
        Constructs a new validator.
        Parameters:
        nodeToValidate - The node to validate.
        attributeDefinitions - The attribute definitions.
      • ObjectNodeValidator

        public ObjectNodeValidator​(org.gcube.com.fasterxml.jackson.databind.node.ObjectNode nodeToValidate,
                                   List<? extends AttributeDefinition> attributeDefinitions,
                                   Boolean stopOnError)
        Constructs a new validator with the option to stop on the first error.
        Parameters:
        nodeToValidate - The node to validate.
        attributeDefinitions - The attribute definitions.
        stopOnError - true to stop on the first error.
    • Method Detail

      • getValidatorReport

        public ValidatorReport getValidatorReport()
        Returns the validator report.
        Returns:
        The validator report.
      • isValid

        public boolean isValid()
        Checks if the validation was successful.
        Returns:
        true if the validation was successful.
      • validate

        public boolean validate()
        Validates the node.
        Returns:
        true if the validation was successful.