<?php

namespace app\models\mikrotik;

use yii\base\Model;

class MikrotikForm extends Model {

    /**
     * @var UploadedFile|Null file attribute
     */
    public $ip;
    public $pwd;
    public $login;

    /**
     * @return array the validation rules.
     */
    public function rules() {
        return [
            ['ip', 'required'],
            [['ip'], 'string'],
            [['pwd'], 'validatepw'],
            [['login'], 'string'],
        ];
    }

    public function validatepw($attribute, $params) {
        if (!ctype_alnum($this->$attribute)) {
            $this->addError($attribute, 'Username should only contain alphabets and numbers');
        }
    }

}
