Changeset 5757
- Timestamp:
- 10/30/07 07:35:06 (1 year ago)
- Files:
-
- trunk/lib/validator/sfValidatorChoice.class.php (modified) (5 diffs)
- trunk/lib/validator/sfValidatorChoiceMany.class.php (modified) (1 diff)
- trunk/test/unit/validator/sfValidatorChoiceManyTest.php (modified) (1 diff)
- trunk/test/unit/validator/sfValidatorChoiceTest.php (modified) (2 diffs)
- trunk/test/unit/validator/sfValidatorFromDescriptionTest.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/lib/validator/sfValidatorChoice.class.php
r5753 r5757 24 24 * Available options: 25 25 * 26 * * expected:An array of expected values26 * * choices: An array of expected values 27 27 * 28 28 * @see sfValidator … … 30 30 public function __construct($options = array(), $messages = array()) 31 31 { 32 if (!isset($options[' expected']))32 if (!isset($options['choices'])) 33 33 { 34 throw new sfException('The " expected" option is mandatory.');34 throw new sfException('The "choices" option is mandatory.'); 35 35 } 36 36 … … 43 43 protected function doClean($value) 44 44 { 45 if (!in_array($value, $this->getOption(' expected')))45 if (!in_array($value, $this->getOption('choices'))) 46 46 { 47 47 throw new sfValidatorError($this, 'invalid', array('value' => $value)); … … 56 56 protected function getOptionsWithoutDefaults() 57 57 { 58 return parent::getOptionsWithoutDefaults(array(' expected' => array('--fake--')));58 return parent::getOptionsWithoutDefaults(array('choices' => array('--fake--'))); 59 59 } 60 60 … … 64 64 protected function getMessagesWithoutDefaults() 65 65 { 66 return parent::getMessagesWithoutDefaults(array(' expected' => array('--fake--')));66 return parent::getMessagesWithoutDefaults(array('choices' => array('--fake--'))); 67 67 } 68 68 } trunk/lib/validator/sfValidatorChoiceMany.class.php
r5753 r5757 31 31 foreach ($values as $value) 32 32 { 33 if (!in_array($value, $this->getOption(' expected')))33 if (!in_array($value, $this->getOption('choices'))) 34 34 { 35 35 throw new sfValidatorError($this, 'invalid', array('value' => $value)); trunk/test/unit/validator/sfValidatorChoiceManyTest.php
r5753 r5757 13 13 $t = new lime_test(5, new lime_output_color()); 14 14 15 $v = new sfValidatorChoiceMany(array(' expected' => array('foo', 'bar')));15 $v = new sfValidatorChoiceMany(array('choices' => array('foo', 'bar'))); 16 16 17 17 // ->clean() trunk/test/unit/validator/sfValidatorChoiceTest.php
r5753 r5757 25 25 } 26 26 27 $v = new sfValidatorChoice(array(' expected' => array('foo', 'bar')));27 $v = new sfValidatorChoice(array('choices' => array('foo', 'bar'))); 28 28 29 29 // ->clean() … … 44 44 // ->asString() 45 45 $t->diag('->asString()'); 46 $t->is($v->asString(), 'Choice({ expected: [foo, bar] })', '->asString() returns a string representation of the validator');46 $t->is($v->asString(), 'Choice({ choices: [foo, bar] })', '->asString() returns a string representation of the validator'); trunk/test/unit/validator/sfValidatorFromDescriptionTest.php
r5753 r5757 105 105 'email:Email and (age:Integer({min: 18}) or (age:Integer({max: 18}) and is_young:Boolean({required: true})))', 106 106 '(password == password_bis) and begin_date <= end_date and password:String({min: 4, max: 18})', 107 'countries:Choice({ expected: [France, USA, Italy, Spain]}) and password ==({invalid: "Passwords must be the same (%left_field% != %right_field%)"}) password_bis and begin_date <= end_date and password:String({min: 4, max: 18})',107 'countries:Choice({choices: [France, USA, Italy, Spain]}) and password ==({invalid: "Passwords must be the same (%left_field% != %right_field%)"}) password_bis and begin_date <= end_date and password:String({min: 4, max: 18})', 108 108 ); 109 109