mirror of
https://github.com/elyby/accounts.git
synced 2025-05-31 14:11:46 +05:30
Implementation of the backend for the OAuth2 clients management
This commit is contained in:
24
common/validators/MinecraftServerAddressValidator.php
Normal file
24
common/validators/MinecraftServerAddressValidator.php
Normal 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, []];
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user