src/Guzzle/Service/Command/AbstractCommand.php
protected function validate()
    {
        // Do not perform request validation/transformation if it is disable
        if ($this[self::DISABLE_VALIDATION]) {
            return;
        }

        $errors = array();
        $validator = $this->getValidator();
        foreach ($this->operation->getParams() as $name => $schema) {
            $value = $this[$name];
            if (!$validator->validate($schema, $value)) {
                $errors = array_merge($errors, $validator->getErrors());
            } elseif ($value !== $this[$name]) {
                // Update the config value if it changed and no validation errors were encountered
                $this->data[$name] = $value;
            }
        }

        // Validate additional parameters
        $hidden = $this[self::HIDDEN_PARAMS];

        if ($properties = $this->operation->getAdditionalParameters()) {
            foreach ($this->toArray() as $name => $value) {
                // It's only additional if it isn't defined in the schema
                if (!$this->operation->hasParam($name) && !in_array($name, $hidden)) {
                    // Always set the name so that error messages are useful
                    $properties->setName($name);
                    if (!$validator->validate($properties, $value)) {
                        $errors = array_merge($errors, $validator->getErrors());
                    } elseif ($value !== $this[$name]) {
                        $this->data[$name] = $value;
                    }
                }
            }
        }

        if (!empty($errors)) {
            $e = new ValidationException('Validation errors: ' . implode("\n", $errors));
            $e->setErrors($errors);
            throw $e;
        }
    }
protected function validate()
    {
        // Do not perform request validation/transformation if it is disable
        if ($this[self::DISABLE_VALIDATION]) {
            return;
        }

        $errors = array();
        $validator = $this->getValidator();
        foreach ($this->operation->getParams() as $name => $schema) {
            $value = $this[$name];
            if (!$validator->validate($schema, $value)) {
                $errors = array_merge($errors, $validator->getErrors());
            } elseif ($value !== $this[$name]) {
                // Update the config value if it changed and no validation errors were encountered
                $this->data[$name] = $value;
            }
        }

        // Validate additional parameters
        $hidden = $this[self::HIDDEN_PARAMS];

        if ($properties = $this->operation->getAdditionalParameters()) {
            foreach ($this->toArray() as $name => $value) {
                // It's only additional if it isn't defined in the schema
                if (!$this->operation->hasParam($name) && !in_array($name, $hidden)) {
                    // Always set the name so that error messages are useful
                    $properties->setName($name);
                    if (!$validator->validate($properties, $value)) {
                        $errors = array_merge($errors, $validator->getErrors());
                    } elseif ($value !== $this[$name]) {
                        $this->data[$name] = $value;
                    }
                }
            }
        }

        if (!empty($errors)) {
            $e = new ValidationException('Validation errors: ' . implode("\n", $errors));
            $e->setErrors($errors);
            throw $e;
        }
    }
protected function validate ( ) { // Do not perform request validation/transformation if it is disable if ( $ this [ self :: DISABLE_VALIDATION ] ) { return ; } $ errors = array ( ) ; $ validator = $ this -> getValidator ( ) ; foreach ( $ this -> operation -> getParams ( ) as $ name => $ schema ) { $ value = $ this [ $ name ] ; if ( ! $ validator -> validate ( $ schema , $ value ) ) { $ errors = array_merge ( $ errors , $ validator -> getErrors ( ) ) ; } elseif ( $ value !== $ this [ $ name ] ) { // Update the config value if it changed and no validation errors were encountered $ this -> data [ $ name ] = $ value ; } } // Validate additional parameters $ hidden = $ this [ self :: HIDDEN_PARAMS ] ; if ( $ properties = $ this -> operation -> getAdditionalParameters ( ) ) { foreach ( $ this -> toArray ( ) as $ name => $ value ) { // It's only additional if it isn't defined in the schema if ( ! $ this -> operation -> hasParam ( $ name ) && ! in_array ( $ name , $ hidden ) ) { // Always set the name so that error messages are useful $ properties -> setName ( $ name ) ; if ( ! $ validator -> validate ( $ properties , $ value ) ) { $ errors = array_merge ( $ errors , $ validator -> getErrors ( ) ) ; } elseif ( $ value !== $ this [ $ name ] ) { $ this -> data [ $ name ] = $ value ; } } } } if ( ! empty ( $ errors ) ) { $ e = new ValidationException ( 'Validation errors: ' . implode ( "\n" , $ errors ) ) ; $ e -> setErrors ( $ errors ) ; throw $ e ; } }
Validate and prepare the command based on the schema and rules defined by the command's Operation object

@throws ValidationException when validation errors occur
Validate and prepare the command based on the schema and rules defined by the command s Operation object