I can not understand how validators work in YII, here comes the post request to the controller:
public function actionAddnewserver() { if (Yii::$app->request->isAjax) { $data = Yii::$app->request->post(); $server = new Server(); $server->insertNewServer($data); } } Before inserting into the database, for example, I want to check $data['url'] for validity. This controller has this method:
/** * @return array the validation rules. */ public function rules() { return [ // Проверяет, что "website" является корректным URL. Добавляет http:// к атрибуту "website". // если у него нет URI схемы ['website', 'url', 'defaultScheme' => 'http', 'message' => 'ошибка'], ]; } This is all I could find from the documentation. How should I understand if the URL correct or not? I work with YII for the first time. Well, logically, I have to pass this string to some boolean method that would return true or false to me, but I don’t understand how to do that.