Development

Changeset 9411

You must first sign up to be able to contribute.

Changeset 9411

Show
Ignore:
Timestamp:
06/02/08 19:02:26 (7 years ago)
Author:
nicolas
Message:

Changed default required option value to false for both sfValidatorAnd and sfValidatorOr validators

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/1.1/lib/validator/sfValidatorAnd.class.php

    r9048 r9411  
    5353    { 
    5454      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; 
    5560    } 
    5661 
  • branches/1.1/lib/validator/sfValidatorOr.class.php

    r9048 r9411  
    5353    { 
    5454      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; 
    5560    } 
    5661 
  • branches/1.1/test/unit/validator/sfValidatorAndTest.php

    r9102 r9411  
    4949try 
    5050{ 
     51  $v->setOption('required', true); 
    5152  $v->clean(null); 
    5253  $t->fail('->clean() throws an sfValidatorError exception if the input value is required'); 
     
    9293$v2 = new sfValidatorString(array('min_length' => 3)); 
    9394$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)" 
    9596, '->asString() returns a string representation of the validator'); 
    9697 
    9798$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)" 
    99100, '->asString() returns a string representation of the validator'); 
  • branches/1.1/test/unit/validator/sfValidatorOrTest.php

    r9103 r9411  
    4949try 
    5050{ 
     51  $v->setOption('required', true); 
    5152  $v->clean(null); 
    5253  $t->fail('->clean() throws an sfValidatorError exception if the input value is required'); 
     
    9899$v2 = new sfValidatorString(array('min_length' => 3)); 
    99100$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)" 
    101102, '->asString() returns a string representation of the validator'); 
    102103 
    103104$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)" 
    105106, '->asString() returns a string representation of the validator');