public function validate($notify = false)
    {
        $validator = $this->getValidator();
        if ($validator) {
            // Expand the schema.
            // TODO: recurse & $value->validate() instead?
            $schema = clone $this->schema;
            $this->resolver->resolve($schema, $this->schema_path);

            // Set to current values.
            $values = $this->flatValue();
            if (isset($values)) {
                $validator->check($values, $schema);
                if (!$validator->isValid()) {
                    $errors = $validator->getErrors();
                    if (empty($errors)) {
                        // Create a top level schema error since something is wrong.
                        $errors = array(array(
                            'property' => $this->schema_path,
                            'message' => 'The JSON schema failed validation.',
                            'constraint' => null,
                        ));
                    }

                    // Log errors.
                    if ($notify) {
                        foreach ($errors as $error) {
                            $error_keys = array(
                              '%name' => $this->schema_name,
                              '%message' => $error['message'],
                              '%property' => isset($error['property']) ? $error['property'] : 'property',
                              '%constraint' => isset($error['constraint']) ? $error['constraint'] : 'unknown',
                            );

                            $this->logger->notice('Schema Validation: "%message" in schema "%name", property "%property" for constraint %constraint', $error_keys);
                        }
                    }

                    return $errors;
                }
            }
        }

        return true;
    }
public function validate($notify = false)
    {
        $validator = $this->getValidator();
        if ($validator) {
            // Expand the schema.
            // TODO: recurse & $value->validate() instead?
            $schema = clone $this->schema;
            $this->resolver->resolve($schema, $this->schema_path);

            // Set to current values.
            $values = $this->flatValue();
            if (isset($values)) {
                $validator->check($values, $schema);
                if (!$validator->isValid()) {
                    $errors = $validator->getErrors();
                    if (empty($errors)) {
                        // Create a top level schema error since something is wrong.
                        $errors = array(array(
                            'property' => $this->schema_path,
                            'message' => 'The JSON schema failed validation.',
                            'constraint' => null,
                        ));
                    }

                    // Log errors.
                    if ($notify) {
                        foreach ($errors as $error) {
                            $error_keys = array(
                              '%name' => $this->schema_name,
                              '%message' => $error['message'],
                              '%property' => isset($error['property']) ? $error['property'] : 'property',
                              '%constraint' => isset($error['constraint']) ? $error['constraint'] : 'unknown',
                            );

                            $this->logger->notice('Schema Validation: "%message" in schema "%name", property "%property" for constraint %constraint', $error_keys);
                        }
                    }

                    return $errors;
                }
            }
        }

        return true;
    }
public function validate ( $ notify = false ) { $ validator = $ this -> getValidator ( ) ; if ( $ validator ) { // Expand the schema. // TODO: recurse & $value->validate() instead? $ schema = clone $ this -> schema ; $ this -> resolver -> resolve ( $ schema , $ this -> schema_path ) ; // Set to current values. $ values = $ this -> flatValue ( ) ; if ( isset ( $ values ) ) { $ validator -> check ( $ values , $ schema ) ; if ( ! $ validator -> isValid ( ) ) { $ errors = $ validator -> getErrors ( ) ; if ( empty ( $ errors ) ) { // Create a top level schema error since something is wrong. $ errors = array ( array ( 'property' => $ this -> schema_path , 'message' => 'The JSON schema failed validation.' , 'constraint' => null , ) ) ; } // Log errors. if ( $ notify ) { foreach ( $ errors as $ error ) { $ error_keys = array ( '%name' => $ this -> schema_name , '%message' => $ error [ 'message' ] , '%property' => isset ( $ error [ 'property' ] ) ? $ error [ 'property' ] : 'property' , '%constraint' => isset ( $ error [ 'constraint' ] ) ? $ error [ 'constraint' ] : 'unknown' , ) ; $ this -> logger -> notice ( 'Schema Validation: "%message" in schema "%name", property "%property" for constraint %constraint' , $ error_keys ) ; } } return $ errors ; } } } return true ; }
Validate a properties value.

@param bool $notify True to log any validation errors. Defaults to false.

@return bool|array True if the values are valid, otherwise an array of errors per JsonSchema\Validator::getErrors().
Validate a properties value .