Validate Collection name

This commit is contained in:
Mike Colagrosso 2024-10-03 23:20:57 -06:00 committed by Alex Cabal
parent 2aae231710
commit 221c2ff347
2 changed files with 12 additions and 0 deletions

View file

@ -55,6 +55,11 @@ class Collection{
public function Validate(): void{
$error = new Exceptions\ValidationException();
$this->Name = trim($this->Name ?? '');
if($this->Name == ''){
$error->Add(new Exceptions\CollectionNameRequiredException());
}
if(strlen($this->Name) > EBOOKS_MAX_STRING_LENGTH){
$error->Add(new Exceptions\StringTooLongException('Collection name: '. $this->Name));
}

View file

@ -0,0 +1,7 @@
<?
namespace Exceptions;
class CollectionNameRequiredException extends AppException{
/** @var string $message */
protected $message = 'Collection name is required.';
}