mirror of
https://github.com/standardebooks/web.git
synced 2025-07-14 02:21:55 -04:00
Some more minor fixes, and checks for the temporary 'todo' tag
This commit is contained in:
parent
f3aa4f35fc
commit
fe03f01393
7 changed files with 58 additions and 13 deletions
|
@ -1,5 +1,15 @@
|
|||
<?
|
||||
use function Safe\preg_match;
|
||||
|
||||
class ArtworkTag extends Tag{
|
||||
// *******
|
||||
// SETTERS
|
||||
// *******
|
||||
|
||||
// protected function SetName($name): void{
|
||||
// $this->_Name =
|
||||
// }
|
||||
|
||||
// *******
|
||||
// GETTERS
|
||||
// *******
|
||||
|
@ -15,15 +25,29 @@ class ArtworkTag extends Tag{
|
|||
// *******
|
||||
// METHODS
|
||||
// *******
|
||||
protected function Validate(): void{
|
||||
public function Validate(): void{
|
||||
$error = new Exceptions\ValidationException();
|
||||
|
||||
$this->Name = mb_strtolower(trim($this->Name));
|
||||
// Collapse spaces into one
|
||||
$this->Name = preg_replace('/[\s]+/ius', ' ', $this->Name);
|
||||
|
||||
if(strlen($this->Name) == 0){
|
||||
$error->Add(new Exceptions\InvalidArtworkTagException());
|
||||
$error->Add(new Exceptions\InvalidArtworkTagNameException());
|
||||
}
|
||||
|
||||
if($this->Url === null || strlen($this->Url) == 0){
|
||||
$error->Add(new Exceptions\InvalidArtworkTagException());
|
||||
if(strlen($this->Name) > ARTWORK_MAX_STRING_LENGTH){
|
||||
$error->Add(new Exceptions\StringTooLongException('Artwork tag: '. $this->Name));
|
||||
}
|
||||
|
||||
if(preg_match('/[^\sa-z0-9]/ius', $this->Name)){
|
||||
$error->Add(new Exceptions\InvalidArtworkTagNameException());
|
||||
}
|
||||
|
||||
// TODO: Remove this once all legacy artworks are cleaned up and approved.
|
||||
// 'todo' is a reserved tag for legacy artworks.
|
||||
if($this->Name == 'todo'){
|
||||
$error->Add(new Exceptions\InvalidArtworkTagNameException());
|
||||
}
|
||||
|
||||
if($error->HasExceptions){
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue