Changeset 9411
- Timestamp:
- 06/02/08 19:02:26 (5 years ago)
- Files:
-
- branches/1.1/lib/validator/sfValidatorAnd.class.php (modified) (1 diff)
- branches/1.1/lib/validator/sfValidatorOr.class.php (modified) (1 diff)
- branches/1.1/test/unit/validator/sfValidatorAndTest.php (modified) (2 diffs)
- branches/1.1/test/unit/validator/sfValidatorOrTest.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/1.1/lib/validator/sfValidatorAnd.class.php
r9048 r9411 53 53 { 54 54 throw new InvalidArgumentException('sfValidatorAnd constructor takes a sfValidatorBase object, or a sfValidatorBase array.'); 55 } 56 57 if (!isset($options['required'])) 58 { 59 $options['required'] = false; 55 60 } 56 61 branches/1.1/lib/validator/sfValidatorOr.class.php
r9048 r9411 53 53 { 54 54 throw new InvalidArgumentException('sfValidatorOr constructor takes a sfValidatorBase object, or a sfValidatorBase array.'); 55 } 56 57 if (!isset($options['required'])) 58 { 59 $options['required'] = false; 55 60 } 56 61 branches/1.1/test/unit/validator/sfValidatorAndTest.php
r9102 r9411 49 49 try 50 50 { 51 $v->setOption('required', true); 51 52 $v->clean(null); 52 53 $t->fail('->clean() throws an sfValidatorError exception if the input value is required'); … … 92 93 $v2 = new sfValidatorString(array('min_length' => 3)); 93 94 $v = new sfValidatorAnd(array($v1, $v2)); 94 $t->is($v->asString(), "(\n String({ max_length: 3 })\n and \n String({ min_length: 3 })\n)"95 $t->is($v->asString(), "(\n String({ max_length: 3 })\n and({ required: false })\n String({ min_length: 3 })\n)" 95 96 , '->asString() returns a string representation of the validator'); 96 97 97 98 $v = new sfValidatorAnd(array($v1, $v2), array(), array('required' => 'This is required.')); 98 $t->is($v->asString(), "(\n String({ max_length: 3 })\n and({ }, { required: 'This is required.' })\n String({ min_length: 3 })\n)"99 $t->is($v->asString(), "(\n String({ max_length: 3 })\n and({ required: false }, { required: 'This is required.' })\n String({ min_length: 3 })\n)" 99 100 , '->asString() returns a string representation of the validator'); branches/1.1/test/unit/validator/sfValidatorOrTest.php
r9103 r9411 49 49 try 50 50 { 51 $v->setOption('required', true); 51 52 $v->clean(null); 52 53 $t->fail('->clean() throws an sfValidatorError exception if the input value is required'); … … 98 99 $v2 = new sfValidatorString(array('min_length' => 3)); 99 100 $v = new sfValidatorOr(array($v1, $v2)); 100 $t->is($v->asString(), "(\n String({ max_length: 3 })\n or \n String({ min_length: 3 })\n)"101 $t->is($v->asString(), "(\n String({ max_length: 3 })\n or({ required: false })\n String({ min_length: 3 })\n)" 101 102 , '->asString() returns a string representation of the validator'); 102 103 103 104 $v = new sfValidatorOr(array($v1, $v2), array(), array('required' => 'This is required.')); 104 $t->is($v->asString(), "(\n String({ max_length: 3 })\n or({ }, { required: 'This is required.' })\n String({ min_length: 3 })\n)"105 $t->is($v->asString(), "(\n String({ max_length: 3 })\n or({ required: false }, { required: 'This is required.' })\n String({ min_length: 3 })\n)" 105 106 , '->asString() returns a string representation of the validator');