appwrite/src/Appwrite/Database/Validator/UID.php

47 lines
788 B
PHP
Raw Normal View History

2019-05-09 06:54:39 +00:00
<?php
namespace Appwrite\Database\Validator;
2019-05-09 06:54:39 +00:00
use Utopia\Validator;
class UID extends Validator
{
/**
* Get Description.
2019-05-09 06:54:39 +00:00
*
* Returns validator description
*
* @return string
*/
public function getDescription()
{
return 'Invalid UID format';
2019-05-09 06:54:39 +00:00
}
/**
* Is valid.
2019-05-09 06:54:39 +00:00
*
* Returns true if valid or false if not.
*
* @param mixed $value
*
2019-05-09 06:54:39 +00:00
* @return bool
*/
public function isValid($value)
{
if ($value === 0) { // TODO Deprecate confition when we get the chance.
return true;
}
if (!is_string($value)) {
return false;
}
2020-10-27 19:44:15 +00:00
if (mb_strlen($value) > 32) {
2020-07-08 09:11:12 +00:00
return false;
2019-05-09 06:54:39 +00:00
}
return true;
}
}