Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

renamed CValidator::$on to be CValidator::$except.

  • Loading branch information...
commit 91495a3d1ad272732784ab918ee23750828d55b5 1 parent 6b1113e
Qiang Xue qiangxue authored
2  CHANGELOG
View
@@ -78,7 +78,7 @@ Version 1.1.11 work in progress
- Enh #675: CDateFormat::format() now returns null if the parameter $time is null (mdomba)
- Enh #690: Added sender name and proper headers for UTF8 encoding when sending e-mail in SiteController->actionContact() (mdomba)
- Enh #766: Added 'userId' to $params in CDbAuthManager::checkAccess() and CPhpAuthManager::checkAccess() (cebe)
-- Enh #666: Added property $off to CValidator, a list of scenarios that the validator should not be applied to (resurtm)
+- Enh #666: Added property $except to CValidator, a list of scenarios that the validator should not be applied to (resurtm)
- Enh #839: CListView::renderItems now resolves view file only once (nizsheanez)
- Enh #938: CFileValidator::sizeToBytes() is now public and available for using in the whole application (resurtm)
- Enh #943: CDateTimeParser is now able to parse short textual representation of month, e.g. Jan, Jun, Aug (resurtm)
16 framework/validators/CValidator.php
View
@@ -107,7 +107,7 @@
* Each array value refers to a scenario name with the same name as its array key.
* @since 1.1.11
*/
- public $off;
+ public $except;
/**
* @var boolean whether attributes listed with this validator should be considered safe for massive assignment.
* Defaults to true.
@@ -154,15 +154,15 @@ public static function createValidator($name,$object,$attributes,$params=array()
else
$on=array();
- if(isset($params['off']))
+ if(isset($params['except']))
{
- if(is_array($params['off']))
- $off=$params['off'];
+ if(is_array($params['except']))
+ $except=$params['except'];
else
- $off=preg_split('/[\s,]+/',$params['off'],-1,PREG_SPLIT_NO_EMPTY);
+ $except=preg_split('/[\s,]+/',$params['except'],-1,PREG_SPLIT_NO_EMPTY);
}
else
- $off=array();
+ $except=array();
if(method_exists($object,$name))
{
@@ -191,7 +191,7 @@ public static function createValidator($name,$object,$attributes,$params=array()
}
$validator->on=empty($on) ? array() : array_combine($on,$on);
- $validator->off=empty($off) ? array() : array_combine($off,$off);
+ $validator->except=empty($except) ? array() : array_combine($except,$except);
return $validator;
}
@@ -245,7 +245,7 @@ public function clientValidateAttribute($object,$attribute)
*/
public function applyTo($scenario)
{
- if(isset($this->off[$scenario]))
+ if(isset($this->except[$scenario]))
return false;
return empty($this->on) || isset($this->on[$scenario]);
}
10 tests/framework/validators/ScenariosTestModel.php
View
@@ -20,26 +20,26 @@ public function rules()
array('title', 'required', 'on'=>'scenario1'),
// scenario1 and scenario2
- array('firstName', 'required', 'off'=>'scenario3, scenario4'),
+ array('firstName', 'required', 'except'=>'scenario3, scenario4'),
// scenario1, scenario2 and scenario3
array('lastName', 'required', 'on'=>array('scenario1', 'scenario2', 'scenario3')),
// scenario1, scenario2 and scenario3
- array('patronymic', 'required', 'off'=>array('scenario4')),
+ array('patronymic', 'required', 'except'=>array('scenario4')),
// scenario1 and scenario3
- array('nickName', 'required', 'on'=>array('scenario1', 'scenario2', 'scenario3'), 'off'=>'scenario2'),
+ array('nickName', 'required', 'on'=>array('scenario1', 'scenario2', 'scenario3'), 'except'=>'scenario2'),
// scenario1, scenario2, scenario3 and scenario4
array('login', 'required'),
// useless rule
array('password', 'required', 'on'=>'scenario1,scenario2,scenario3,scenario4',
- 'off'=>array('scenario1', 'scenario2', 'scenario3', 'scenario4')),
+ 'except'=>array('scenario1', 'scenario2', 'scenario3', 'scenario4')),
// scenario2
- array('birthday', 'required', 'on'=>'scenario2', 'off'=>'scenario3'),
+ array('birthday', 'required', 'on'=>'scenario2', 'except'=>'scenario3'),
);
}
}

3 comments on commit 91495a3

Carsten Brandt
Collaborator

@qiangxue docs need to be adjusted then too.

Alexandr Bordun

That's already done
a1f7e33

Carsten Brandt
Collaborator

ah k, haven't pulled that, sry :)

Please sign in to comment.
Something went wrong with that request. Please try again.