/** * Returns this model's validation rules. * * @return array */ public function rules() { $rules = parent::rules(); // Use Yii's stricter URL validator here $rules[] = array('url', 'url'); return $rules; }
/** * Define validation rules * * @return array with validation rules */ public function rules() { // add the custom validator for validating Project Id $rules = parent::rules(); $rules[] = array('projectId', 'Craft\\Optimizely_ProjectIdValidator'); return $rules; }
/** * @inheritDoc BaseModel::rules() * * @return array */ public function rules() { $rules = parent::rules(); if ($this->urlFormatIsRequired) { $rules[] = array('urlFormat', 'required'); } if ($this->nestedUrlFormatIsRequired) { $rules[] = array('nestedUrlFormat', 'required'); } return $rules; }
/** * @inheritDoc BaseModel::rules() * * @return array */ public function rules() { $rules = parent::rules(); if ($this->decimals && intval($this->decimals) && intval($this->decimals) > 0) { foreach ($rules as $key => &$rule) { if (isset($rule[0]) && isset($rule[1]) && ($rule[0] == 'min' || $rule[0] == 'max') && $rule[1] == 'numerical') { $rule['integerOnly'] = false; } } } return $rules; }
/** * @inheritDoc BaseModel::rules() * * @return array */ public function rules() { $rules = parent::rules(); if ($this->expectedPrice == 0) { // CC info not required foreach ($rules as &$rule) { if ($rule[1] == 'required') { $attributes = explode(',', $rule[0]); foreach (array('ccTokenId', 'expMonth', 'expYear') as $attribute) { $pos = array_search($attribute, $attributes); if ($pos !== false) { array_splice($attributes, $pos, 1); } } $rule[0] = implode(',', $attributes); break; } } } return $rules; }
public function rules() { $rules = parent::rules(); $rules[] = ['numberOfCrops', 'validateNumberOfCrops']; return $rules; }
public function rules() { // maxSize is 3MB return array_merge(parent::rules(), array(array('attachment', 'file', 'maxSize' => 3145728, 'allowEmpty' => true))); }