I wrote a function that creates a 6-digits number.
how can I validate this number manually without using models in yii2?
i think it's useful:
<?php
public function actionValidation(){
$model = new \yii\base\DynamicModel(['number']);
$model->addRule('number', 'integer', ['message'=>'should be a number']);
$model->number = $this->yourFunction();
Yii::$app->response->format = Response::FORMAT_JSON;
return ActiveForm::validate($model);
}
public function yourFunction(){
return 6-digits-number;
}
?>