src/Node/Node.php
public function validate(array $options = [])
    {
        $options = array_replace(
            [
                'validateMinChildren'               => true,
                'validateMaxChildren'               => true,
                'validateParentMandatory'           => true,
                'validateParentMustNotBeSet'        => true
            ],
            $options
        );

        $countChildren = $this->countChildren();

        if ($options['validateMinChildren']
            && ($min = $this->getValidationConfig('minChildren')) !== null
            && $min > $countChildren
        ) {
            throw ValidationException::create(
                'Children must be, at least, ' . $min . '. Currently, node "' . $this->getId() . '" has ' .
                $countChildren . ' children.'
            );
        }

        if ($options['validateMaxChildren']
            && ($max = $this->getValidationConfig('maxChildren')) !== null
            && $max < $countChildren
        ) {
            throw ValidationException::create(
                'Children cannot exceed a maximum of ' . $max . '. Currently, node "' . $this->getId() . '" has ' .
                $countChildren . ' children.'
            );
        }

        if ($options['validateParentMandatory']
            && $this->getValidationConfig('parentMandatory')
            && $this->getParent() === null
        ) {
            throw ValidationException::create(
                'Node "' . $this->getId() . '" must have a Parent!'
            );
        }

        if ($options['validateParentMustNotBeSet']
            && $this->getValidationConfig('parentMustNotBeSet')
            && $this->getParent() !== null
        ) {
            throw ValidationException::create(
                'Node "' . $this->getId() . '" must NOT have a Parent!'
            );
        }
    }
public function validate(array $options = [])
    {
        $options = array_replace(
            [
                'validateMinChildren'               => true,
                'validateMaxChildren'               => true,
                'validateParentMandatory'           => true,
                'validateParentMustNotBeSet'        => true
            ],
            $options
        );

        $countChildren = $this->countChildren();

        if ($options['validateMinChildren']
            && ($min = $this->getValidationConfig('minChildren')) !== null
            && $min > $countChildren
        ) {
            throw ValidationException::create(
                'Children must be, at least, ' . $min . '. Currently, node "' . $this->getId() . '" has ' .
                $countChildren . ' children.'
            );
        }

        if ($options['validateMaxChildren']
            && ($max = $this->getValidationConfig('maxChildren')) !== null
            && $max < $countChildren
        ) {
            throw ValidationException::create(
                'Children cannot exceed a maximum of ' . $max . '. Currently, node "' . $this->getId() . '" has ' .
                $countChildren . ' children.'
            );
        }

        if ($options['validateParentMandatory']
            && $this->getValidationConfig('parentMandatory')
            && $this->getParent() === null
        ) {
            throw ValidationException::create(
                'Node "' . $this->getId() . '" must have a Parent!'
            );
        }

        if ($options['validateParentMustNotBeSet']
            && $this->getValidationConfig('parentMustNotBeSet')
            && $this->getParent() !== null
        ) {
            throw ValidationException::create(
                'Node "' . $this->getId() . '" must NOT have a Parent!'
            );
        }
    }
public function validate ( array $ options = [ ] ) { $ options = array_replace ( [ 'validateMinChildren' => true , 'validateMaxChildren' => true , 'validateParentMandatory' => true , 'validateParentMustNotBeSet' => true ] , $ options ) ; $ countChildren = $ this -> countChildren ( ) ; if ( $ options [ 'validateMinChildren' ] && ( $ min = $ this -> getValidationConfig ( 'minChildren' ) ) !== null && $ min > $ countChildren ) { throw ValidationException :: create ( 'Children must be, at least, ' . $ min . '. Currently, node "' . $ this -> getId ( ) . '" has ' . $ countChildren . ' children.' ) ; } if ( $ options [ 'validateMaxChildren' ] && ( $ max = $ this -> getValidationConfig ( 'maxChildren' ) ) !== null && $ max < $ countChildren ) { throw ValidationException :: create ( 'Children cannot exceed a maximum of ' . $ max . '. Currently, node "' . $ this -> getId ( ) . '" has ' . $ countChildren . ' children.' ) ; } if ( $ options [ 'validateParentMandatory' ] && $ this -> getValidationConfig ( 'parentMandatory' ) && $ this -> getParent ( ) === null ) { throw ValidationException :: create ( 'Node "' . $ this -> getId ( ) . '" must have a Parent!' ) ; } if ( $ options [ 'validateParentMustNotBeSet' ] && $ this -> getValidationConfig ( 'parentMustNotBeSet' ) && $ this -> getParent ( ) !== null ) { throw ValidationException :: create ( 'Node "' . $ this -> getId ( ) . '" must NOT have a Parent!' ) ; } }
This method is called after initializing the data.

@param array $options - Options.

@throws ValidationException

@return void
This method is called after initializing the data .