Index: trunk/extensions/Validator/includes/criteria/CriterionInArray.php |
— | — | @@ -29,10 +29,20 @@ |
30 | 30 | * |
31 | 31 | * @since 0.4 |
32 | 32 | */ |
33 | | - public function __construct( $allowedValues ) { |
| 33 | + public function __construct() { |
34 | 34 | parent::__construct(); |
35 | 35 | |
36 | | - $this->allowedValues = (array)$allowedValues; |
| 36 | + $args = func_get_args(); |
| 37 | + |
| 38 | + if ( count( $args ) > 1 ) { |
| 39 | + $this->allowedValues = $args; |
| 40 | + } |
| 41 | + elseif ( count( $args ) == 1 ) { |
| 42 | + $this->allowedValues = (array)$args[0]; |
| 43 | + } |
| 44 | + else { |
| 45 | + $this->allowedValues = array(); |
| 46 | + } |
37 | 47 | } |
38 | 48 | |
39 | 49 | /** |
Index: trunk/extensions/Validator/includes/Parameter.php |
— | — | @@ -535,30 +535,27 @@ |
536 | 536 | protected function getCriteriaForType() { |
537 | 537 | $criteria = array(); |
538 | 538 | |
539 | | - /* TODO |
540 | 539 | switch( $this->type ) { |
541 | | - case TYPE_INTEGER: |
542 | | - $criteria[] = 'is_integer'; |
| 540 | + case self::TYPE_INTEGER: |
| 541 | + $criteria[] = new CriterionIsInteger(); |
543 | 542 | break; |
544 | | - case TYPE_FLOAT: |
545 | | - $criteria[] = 'is_float'; |
| 543 | + case self::TYPE_FLOAT: |
| 544 | + $criteria[] = new CriterionIsFloat(); |
546 | 545 | break; |
547 | | - case TYPE_NUMBER: // Note: This accepts non-decimal notations! |
548 | | - $criteria[] = 'is_numeric'; |
| 546 | + case self::TYPE_FLOAT: // Note: This accepts non-decimal notations! |
| 547 | + $criteria[] = new CriterionIsNumeric(); |
549 | 548 | break; |
550 | | - case TYPE_BOOLEAN: |
551 | | - // TODO: work with list of true and false values. |
552 | | - // TODO: i18n |
553 | | - $criteria[] = array( 'in_array' => array( 'yes', 'no', 'on', 'off' ) ); |
| 549 | + case self::TYPE_BOOLEAN: |
| 550 | + // TODO: work with list of true and false values and i18n. |
| 551 | + $criteria[] = new CriterionInArray( 'yes', 'no', 'on', 'off' ); |
554 | 552 | break; |
555 | | - case TYPE_CHAR: |
556 | | - $criteria[] = array( 'has_length' => array( 1, 1 ) ); |
| 553 | + case self::TYPE_CHAR: |
| 554 | + $criteria[] = new CriterionHasLength( 1, 1 ); |
557 | 555 | break; |
558 | | - case TYPE_STRING: default: |
| 556 | + case self::TYPE_STRING: default: |
559 | 557 | // No extra criteria for strings. |
560 | 558 | break; |
561 | 559 | } |
562 | | - */ |
563 | 560 | |
564 | 561 | return $criteria; |
565 | 562 | } |
— | — | @@ -571,7 +568,6 @@ |
572 | 569 | * @return array |
573 | 570 | */ |
574 | 571 | public function getListCriteria() { |
575 | | - // TODO |
576 | 572 | return array(); |
577 | 573 | } |
578 | 574 | |