/**
  * Validation will only be performed on input keys not on all field keys to
  * allow for partial input validation.
  *
  * @param array input
  *
  * @return array errors (empty if no errors)
  */
 function validate($input)
 {
     $errors = array();
     $defaults = custom_body_class::defaults();
     $plugin_checks = $this->meta->get('checks', array());
     foreach ($input as $key => $value) {
         $field = $this->fields->get($key);
         // Calculate validation rules
         // --------------------------
         $rules = array();
         // check custom_body_class defaults
         if (isset($defaults['checks'][$field['type']])) {
             $rules = $defaults['checks'][$field['type']];
         }
         // check theme defaults
         if (isset($plugin_checks[$field['type']])) {
             $rules = array_merge($rules, $plugin_checks[$field['type']]);
         }
         // check field presets
         if (isset($field['checks'])) {
             $rules = array_merge($rules, $field['checks']);
         }
         // Perform validation
         // ------------------
         foreach ($rules as $rule) {
             $callback = custom_body_class::callback($rule, $this->meta);
             $valid = call_user_func($callback, $input[$key], $field, $this);
             if (!$valid) {
                 isset($errors[$key]) or $errors[$key] = array();
                 $errors[$key][$rule] = $this->error_message($rule);
             }
         }
     }
     return $errors;
 }
 /**
  * Execute postupdate hooks on input.
  */
 protected function postupdate($input)
 {
     $defaults = custom_body_class::defaults();
     $plugin_hooks = $this->meta->get('processor', array('preupdate' => array(), 'postupdate' => array()));
     // Calculate hooks
     // ---------------
     $hooks = array();
     // check custom_body_class defaults
     if (isset($defaults['processor']['postupdate'])) {
         $hooks = $defaults['processor']['postupdate'];
     }
     // check plugin defaults
     if (isset($plugin_hooks['postupdate'])) {
         $hooks = array_merge($hooks, $plugin_hooks['postupdate']);
     }
     // Execute hooks
     // -------------
     foreach ($hooks as $rule) {
         $callback = custom_body_class::callback($rule, $this->meta);
         call_user_func($callback, $input, $this);
     }
 }