src/Schema.php
protected function validateObject($value, ValidationField $field) {
        if (!$this->isArray($value) || isset($value[0])) {
            $field->addTypeError($value, 'object');
            return Invalid::value();
        } elseif (is_array($field->val('properties')) || null !== $field->val('additionalProperties')) {
            // Validate the data against the internal schema.
            $value = $this->validateProperties($value, $field);
        } elseif (!is_array($value)) {
            $value = $this->toObjectArray($value);
        }

        if (($maxProperties = $field->val('maxProperties')) && count($value) > $maxProperties) {
            $field->addError(
                'maxProperties',
                [
                    'messageCode' => 'This must contain no more than {maxProperties} {maxProperties,plural,item,items}.',
                    'maxItems' => $maxProperties,
                ]
            );
        }

        if (($minProperties = $field->val('minProperties')) && count($value) < $minProperties) {
            $field->addError(
                'minProperties',
                [
                    'messageCode' => 'This must contain at least {minProperties} {minProperties,plural,item,items}.',
                    'minItems' => $minProperties,
                ]
            );
        }

        return $value;
    }
protected function validateObject($value, ValidationField $field) {
        if (!$this->isArray($value) || isset($value[0])) {
            $field->addTypeError($value, 'object');
            return Invalid::value();
        } elseif (is_array($field->val('properties')) || null !== $field->val('additionalProperties')) {
            // Validate the data against the internal schema.
            $value = $this->validateProperties($value, $field);
        } elseif (!is_array($value)) {
            $value = $this->toObjectArray($value);
        }

        if (($maxProperties = $field->val('maxProperties')) && count($value) > $maxProperties) {
            $field->addError(
                'maxProperties',
                [
                    'messageCode' => 'This must contain no more than {maxProperties} {maxProperties,plural,item,items}.',
                    'maxItems' => $maxProperties,
                ]
            );
        }

        if (($minProperties = $field->val('minProperties')) && count($value) < $minProperties) {
            $field->addError(
                'minProperties',
                [
                    'messageCode' => 'This must contain at least {minProperties} {minProperties,plural,item,items}.',
                    'minItems' => $minProperties,
                ]
            );
        }

        return $value;
    }
protected function validateObject ( $ value , ValidationField $ field ) { if ( ! $ this -> isArray ( $ value ) || isset ( $ value [ 0 ] ) ) { $ field -> addTypeError ( $ value , 'object' ) ; return Invalid :: value ( ) ; } elseif ( is_array ( $ field -> val ( 'properties' ) ) || null !== $ field -> val ( 'additionalProperties' ) ) { // Validate the data against the internal schema. $ value = $ this -> validateProperties ( $ value , $ field ) ; } elseif ( ! is_array ( $ value ) ) { $ value = $ this -> toObjectArray ( $ value ) ; } if ( ( $ maxProperties = $ field -> val ( 'maxProperties' ) ) && count ( $ value ) > $ maxProperties ) { $ field -> addError ( 'maxProperties' , [ 'messageCode' => 'This must contain no more than {maxProperties} {maxProperties,plural,item,items}.' , 'maxItems' => $ maxProperties , ] ) ; } if ( ( $ minProperties = $ field -> val ( 'minProperties' ) ) && count ( $ value ) < $ minProperties ) { $ field -> addError ( 'minProperties' , [ 'messageCode' => 'This must contain at least {minProperties} {minProperties,plural,item,items}.' , 'minItems' => $ minProperties , ] ) ; } return $ value ; }
Validate an object.

@param mixed $value The value to validate.
@param ValidationField $field The validation results to add.
@return object|Invalid Returns a clean object or **null** if validation fails.
@throws RefNotFoundException Throws an exception when a schema `$ref` is not found.
Validate an object .