accounts/api/modules/authserver/validators/ClientTokenValidator.php

29 lines
705 B
PHP
Raw Normal View History

2018-01-02 20:22:56 +03:00
<?php
declare(strict_types=1);
2018-01-02 20:22:56 +03:00
namespace api\modules\authserver\validators;
use api\modules\authserver\exceptions\IllegalArgumentException;
use yii\validators\Validator;
2018-01-02 20:22:56 +03:00
/**
* The maximum length of clientToken for our database is 255.
* If the token is longer, we do not accept the passed token at all.
2018-01-02 20:22:56 +03:00
*/
class ClientTokenValidator extends Validator {
2018-01-02 20:22:56 +03:00
/**
* @param string $value
* @return null
* @throws \api\modules\authserver\exceptions\AuthserverException
*/
protected function validateValue($value): ?array {
2018-01-02 20:22:56 +03:00
if (mb_strlen($value) > 255) {
throw new IllegalArgumentException('clientToken is too long.');
}
return null;
}
}