Ejemplo n.º 1
0
 /**
  * @inheritdoc
  */
 public function rules()
 {
     return [[['phone', 'email'], 'required'], [['name', 'email'], 'string', 'max' => 50], ['name', 'required', 'when' => function ($model) {
         return $model->subject_id < 1;
     }], ['name', NameValidator::className(), 'when' => function ($model) {
         return $model->subject_id < 1;
     }], ['email', 'email'], ['phone', 'string', 'max' => 20], [['time_from', 'time_to'], 'integer', 'on' => self::SCENARIO_CREATE], ['time_from', 'compare', 'compareAttribute' => 'time_to', 'operator' => '<', 'type' => 'number', 'on' => self::SCENARIO_CREATE], ['repetition_end_date', 'date', 'format' => 'y-MM-dd', 'on' => self::SCENARIO_CREATE], ['repetition_end_date', DateToDateValidator::className(), 'compareAttribute' => 'date', 'operator' => '>=', 'on' => self::SCENARIO_CREATE], ['repetition', RepetitionValidator::className(), 'limitsAttributes' => ['time_from', 'time_to'], 'on' => self::SCENARIO_CREATE], ['notice', 'string'], [['date', 'subject_id'], 'safe'], [['device_id', 'hour_nr'], 'safe', 'on' => self::SCENARIO_UPDATE]];
 }
Ejemplo n.º 2
0
 /**
  * @inheritdoc
  */
 public function rules()
 {
     return [[['name', 'email', 'phone'], 'required'], [['name', 'email'], 'string', 'max' => 50], ['email', 'email'], [['phone'], 'string', 'max' => 20], ['name', NameValidator::className()]];
 }