/** * @inheritdoc */ public function rules() { return [[['userUid'], 'string', 'length' => 36], [['firstName', 'lastName'], 'string', 'max' => 255], ['birthday', DateValidator::className(), 'format' => 'dd.MM.yyyy'], ['phone', PhoneValidator::className()]]; }
/** * Performs validation for all the attributes * @param Event $event */ public function onBeforeValidate($event) { foreach ($this->attributeValues as $name => $value) { $options = ArrayHelper::merge(['class' => DateValidator::className(), 'format' => $value->localFormat[1]], $this->validatorOptions); $validator = Yii::createObject($options); $validator->validateAttributes($this->owner, [$value->localAttribute]); } }
/** * Performs validation for all the attributes * @param Event $event */ public function onBeforeValidate($event) { foreach ($this->attributeValues as $targetAttribute => $value) { if ($value instanceof DateTimeAttribute) { $validator = \Yii::createObject(['class' => DateValidator::className(), 'format' => self::normalizeIcuFormat($value->targetFormat, $this->formatter)[1]]); $validator->validateAttribute($this->owner, $targetAttribute); } } }