1
0
Fork 0
mirror of synced 2024-05-20 12:42:39 +12:00
appwrite/src/Appwrite/Storage/Validator/FileName.php
Eldad A. Fux 042660b15c
Feat psalm analysis (#699)
* Added static code analysis
* Updated code to solve psalm issue
2020-10-27 02:08:29 +02:00

38 lines
648 B
PHP

<?php
namespace Appwrite\Storage\Validator;
use Utopia\Validator;
class FileName extends Validator
{
public function getDescription()
{
return 'Filename is not valid';
}
/**
* The file name can only contain "a-z", "A-Z", "0-9" and "-" and not empty.
*
* @param mixed $name
*
* @return bool
*/
public function isValid($name)
{
if (empty($name)) {
return false;
}
if(!is_string($name)) {
return false;
}
if (!\preg_match('/^[a-zA-Z0-9.]+$/', $name)) {
return false;
}
return true;
}
}