Utilities for common tasks.
VatNumberValidator validator validates if a string or integer can be a valid VAT number. This does not validate if a VAT number is registered for use.
Validaror Parameters
- allowEmpty, boolean: Whether to allow empty value or not
Example rule
['afm', VatNumberValidator::className(), 'allowEmpty' => false],
DefaultOnOtherAttributeValidator
sets a default value otherAttributeValue
on another attibute named
otherAttribute
, if that attribute does not have a value and
if the value of the checked attribute is a certain one (if
), or when
replace
is set to true.
Validaror Parameters
- if, scalar: The value to check against the attribute value (not strict operator used)
- otherAttributeValue, any value: The "default" value to set
- otherAttribute, string: The name of the attribute to set (if empty)
- replace, boolean: Set to true to force set otherAttribute
Example rule
[['do_action'], DefaultOnOtherAttributeValidator::className(), 'if' => 'yes', 'otherAttributeValue' => -1, 'otherAttribute' => 'selected_action_element'],
This is also covered by core Yii functionality
[
'otherAttribute', 'filter',
'filter' => function ($value) {
return $otherAttributeValue;
},
'when' => function($model) {
return $model->attribute == $if;
}
],