Permalink
Browse files

moving option validation to the task class

  • Loading branch information...
1 parent e8dd7bf commit b45a945fa4e63b9c24442b7a049b4da877d0f84e @Zeelot Zeelot committed Feb 28, 2012
Showing with 10 additions and 35 deletions.
  1. +10 −1 classes/Kohana/Minion/Task.php
  2. +0 −25 classes/Kohana/Minion/Valid.php
  3. +0 −9 classes/Minion/Valid.php
@@ -157,7 +157,7 @@ public function build_validation(Validation $validation)
// Add a rule to each key making sure it's in the task
foreach ($validation->as_array() as $key => $value)
{
- $validation->rule($key, array('Minion_Valid', 'option'), array(':validation', ':field', $this));
+ $validation->rule($key, array($this, 'valid_option'), array(':validation', ':field'));
}
return $validation;
@@ -222,4 +222,13 @@ protected function _help(array $params)
echo $view;
}
+
+
+ public function valid_option(Validation $validation, $option)
+ {
+ if ( ! in_array($option, $this->_accepted_options))
+ {
+ $validation->error($key, 'minion_option');
+ }
+ }
}
@@ -1,25 +0,0 @@
-<?php defined('SYSPATH') or die('No direct script access.');
-/**
- * Minion valid class
- *
- * @package Kohana
- * @category Minion
- * @author Kohana Team
- * @copyright (c) 2009-2011 Kohana Team
- * @license http://kohanaframework.org/license
- */
-class Kohana_Minion_Valid
-{
- /**
- * Validates that an option is part of a task
- *
- * @return null
- */
- public static function option(Validation $v, $key, Minion_Task $task)
- {
- if ( ! array_key_exists($key, $task->get_accepted_options()))
- {
- $v->error($key, 'minion_option');
- }
- }
-}
View
@@ -1,9 +0,0 @@
-<?php defined('SYSPATH') or die('No direct script access.');
-
-
-/**
- * Utility class for Minion
- */
-class Minion_Valid extends Kohana_Minion_Valid {
-
-}

0 comments on commit b45a945

Please sign in to comment.