public function validateNode(Node $node, $mode = 'edit')
 {
     // Validates all fields, metas, and tags defined in the current scope
     $this->Logger->debug('Validating node [' . $node->getNodeRef() . '] with partials [' . $node->getNodePartials() . ']');
     // Fields
     // Check the model schema for NodeDBMeta to check fields
     foreach ($this->NodeDBMeta->getModelSchema() as $fieldName => $props) {
         $value = $node->{$fieldName};
         $fieldResolved = $this->resolveField($node->getNodeRef(), $fieldName);
         $title = isset($props['title']) ? $props['title'] : StringUtils::titleize($fieldName);
         $validation = $props['validation'];
         if ($fieldName == 'Slug' && $node->getNodeRef()->getElement()->isAllowSlugSlashes()) {
             $validation['datatype'] = 'slugwithslash';
         }
         if ($fieldName != 'Slug' || $fieldName == 'Slug' && !$this->getErrors()->hasFieldError($this->resolveField($node->getNodeRef(), 'Title'))) {
             $this->getErrors()->rejectIfInvalid($fieldResolved, 'field', $title, $value, new ValidationExpression($validation));
         }
     }
     // SCHEMA VALIDATION
     $schema = $node->getNodeRef()->getElement()->getSchema();
     // Validate tags scope
     // Find all meta tags and validate them against the partials string
     $this->validateMetaPartials($node->getNodePartials()->getMetaPartials(), $node->getMetas(), $schema);
     // Validate OutTag scope
     $node->setOutTags($this->validateTagPartials('out', $node->getNodePartials()->getOutPartials(), $node->getOutTags(), $schema));
     // Validate InTag scope
     $node->setInTags($this->validateTagPartials('in', $node->getNodePartials()->getInPartials(), $node->getInTags(), $schema));
     // Validate Sections scope
     //$this->validateSectionPartials($node->getNodePartials()->getSectionPartials(), $node->getSections(), $schema);
     // Validate metas
     $this->validateMetas($node, $node, $schema, $mode);
     // Validate tags
     $this->validateTags($node, $node, $schema);
     // Sections
     //        if (is_array($node->getSections())) {
     //            $section_type_counts = array();
     //            foreach( $node->getSections() as $key => $section ) {
     //                $section_type = $section->getSectionType();
     //                $section_def  = $schema->getSectionDef($section_type);
     //
     //                @$section_type_counts[$section_type]++;
     //
     //                $section_title = $section_def->Title;
     //                if ($section_def->Max == '*' || (integer)$section_def->Max > 1) {
     //                    $section_title .= " #" . $section_type_counts[$section_type];
     //                }
     //
     //                // Validate Schema Metas
     //                $this->validateMetas($node, $section, $section_def);
     //
     //                // Validate Schema Tags
     //                $this->validateTags($node, $section, $section_def);
     //            }
     //        }
     return $this->getErrors();
 }