mirror of
https://github.com/standardebooks/web.git
synced 2025-07-05 14:20:29 -04:00
Validate Collection name
This commit is contained in:
parent
2aae231710
commit
221c2ff347
2 changed files with 12 additions and 0 deletions
|
@ -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));
|
||||
}
|
||||
|
|
7
lib/Exceptions/CollectionNameRequiredException.php
Normal file
7
lib/Exceptions/CollectionNameRequiredException.php
Normal file
|
@ -0,0 +1,7 @@
|
|||
<?
|
||||
namespace Exceptions;
|
||||
|
||||
class CollectionNameRequiredException extends AppException{
|
||||
/** @var string $message */
|
||||
protected $message = 'Collection name is required.';
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue