Implementation of the backend for the OAuth2 clients management

This commit is contained in:
ErickSkrauch
2018-02-28 01:27:35 +03:00
parent ddec87e3a9
commit 673429e577
55 changed files with 1810 additions and 65 deletions

View File

@@ -0,0 +1,24 @@
<?php
declare(strict_types=1);
namespace common\validators;
use yii\validators\Validator;
class MinecraftServerAddressValidator extends Validator {
protected function validateValue($value) {
// we will add minecraft protocol to help parse_url understand all another parts
$urlParts = parse_url('minecraft://' . $value);
$cnt = count($urlParts);
// scheme will be always presented, so we need to increase expected $cnt by 1
if (($cnt === 3 && isset($urlParts['host'], $urlParts['port']))
|| ($cnt === 2 && isset($urlParts['host']))
) {
return null;
}
return [$this->message, []];
}
}