cs fix
This commit is contained in:
@@ -29,14 +29,16 @@
|
||||
|
||||
namespace Espo\Core\FieldValidators;
|
||||
|
||||
use Espo\ORM\Entity;
|
||||
|
||||
class ArrayType extends BaseType
|
||||
{
|
||||
public function checkRequired(\Espo\ORM\Entity $entity, string $field, $validationValue, $data) : bool
|
||||
public function checkRequired(Entity $entity, string $field, $validationValue, $data) : bool
|
||||
{
|
||||
return $this->isNotEmpty($entity, $field);
|
||||
}
|
||||
|
||||
public function checkMaxCount(\Espo\ORM\Entity $entity, string $field, $validationValue, $data) : bool
|
||||
public function checkMaxCount(Entity $entity, string $field, $validationValue, $data) : bool
|
||||
{
|
||||
if (!$this->isNotEmpty($entity, $field)) return true;
|
||||
$list = $entity->get($field);
|
||||
@@ -44,7 +46,7 @@ class ArrayType extends BaseType
|
||||
return true;
|
||||
}
|
||||
|
||||
public function checkArray(\Espo\ORM\Entity $entity, string $field, $validationValue, $data) : bool
|
||||
public function checkArray(Entity $entity, string $field, $validationValue, $data) : bool
|
||||
{
|
||||
if (isset($data->$field) && $data->$field !== null && !is_array($data->$field)) {
|
||||
return false;
|
||||
@@ -53,7 +55,7 @@ class ArrayType extends BaseType
|
||||
return true;
|
||||
}
|
||||
|
||||
protected function isNotEmpty(\Espo\ORM\Entity $entity, $field)
|
||||
protected function isNotEmpty(Entity $entity, $field)
|
||||
{
|
||||
if (!$entity->has($field) || $entity->get($field) === null) return false;
|
||||
$list = $entity->get($field);
|
||||
|
||||
@@ -29,14 +29,19 @@
|
||||
|
||||
namespace Espo\Core\FieldValidators;
|
||||
|
||||
use \Espo\ORM\Entity;
|
||||
use Espo\ORM\Entity;
|
||||
|
||||
use Espo\Core\{
|
||||
Utils\Metadata,
|
||||
Utils\FieldManagerUtil,
|
||||
};
|
||||
|
||||
class BaseType
|
||||
{
|
||||
private $metadata;
|
||||
private $fieldManagerUtil;
|
||||
protected $metadata;
|
||||
protected $fieldManagerUtil;
|
||||
|
||||
public function __construct(\Espo\Core\Utils\Metadata $metadata, \Espo\Core\Utils\FieldManagerUtil $fieldManagerUtil)
|
||||
public function __construct(Metadata $metadata, FieldManagerUtil $fieldManagerUtil)
|
||||
{
|
||||
$this->metadata = $metadata;
|
||||
$this->fieldManagerUtil = $fieldManagerUtil;
|
||||
@@ -47,12 +52,12 @@ class BaseType
|
||||
return $this->getFieldManagerUtil()->getActualAttributeList($entity->getEntityType(), $field);
|
||||
}
|
||||
|
||||
protected function getMetadata() : \Espo\Core\Utils\Metadata
|
||||
protected function getMetadata() : Metadata
|
||||
{
|
||||
return $this->metadata;
|
||||
}
|
||||
|
||||
protected function getFieldManagerUtil() : \Espo\Core\Utils\FieldManagerUtil
|
||||
protected function getFieldManagerUtil() : FieldManagerUtil
|
||||
{
|
||||
return $this->fieldManagerUtil;
|
||||
}
|
||||
|
||||
@@ -29,9 +29,11 @@
|
||||
|
||||
namespace Espo\Core\FieldValidators;
|
||||
|
||||
use Espo\ORM\Entity;
|
||||
|
||||
class CurrencyType extends FloatType
|
||||
{
|
||||
protected function isNotEmpty(\Espo\ORM\Entity $entity, $field)
|
||||
protected function isNotEmpty(Entity $entity, $field)
|
||||
{
|
||||
return
|
||||
$entity->has($field) && $entity->get($field) !== null &&
|
||||
|
||||
@@ -29,14 +29,16 @@
|
||||
|
||||
namespace Espo\Core\FieldValidators;
|
||||
|
||||
use Espo\ORM\Entity;
|
||||
|
||||
class DateType extends BaseType
|
||||
{
|
||||
public function checkRequired(\Espo\ORM\Entity $entity, string $field, $validationValue, $data) : bool
|
||||
public function checkRequired(Entity $entity, string $field, $validationValue, $data) : bool
|
||||
{
|
||||
return $this->isNotEmpty($entity, $field);
|
||||
}
|
||||
|
||||
protected function isNotEmpty(\Espo\ORM\Entity $entity, $field)
|
||||
protected function isNotEmpty(Entity $entity, $field)
|
||||
{
|
||||
return $entity->has($field) && $entity->get($field) !== null;
|
||||
}
|
||||
|
||||
@@ -29,14 +29,16 @@
|
||||
|
||||
namespace Espo\Core\FieldValidators;
|
||||
|
||||
use Espo\ORM\Entity;
|
||||
|
||||
class DatetimeOptionalType extends DatetimeType
|
||||
{
|
||||
public function checkRequired(\Espo\ORM\Entity $entity, string $field, $validationValue, $data) : bool
|
||||
public function checkRequired(Entity $entity, string $field, $validationValue, $data) : bool
|
||||
{
|
||||
return $this->isNotEmpty($entity, $field);
|
||||
}
|
||||
|
||||
protected function isNotEmpty(\Espo\ORM\Entity $entity, $field)
|
||||
protected function isNotEmpty(Entity $entity, $field)
|
||||
{
|
||||
if ($entity->has($field) && $entity->get($field) !== null) return true;
|
||||
if ($entity->has($field . 'Date') && $entity->get($field . 'Date') !== null) return true;
|
||||
|
||||
@@ -29,9 +29,11 @@
|
||||
|
||||
namespace Espo\Core\FieldValidators;
|
||||
|
||||
use Espo\ORM\Entity;
|
||||
|
||||
class EmailType extends BaseType
|
||||
{
|
||||
public function checkRequired(\Espo\ORM\Entity $entity, string $field, $validationValue, $data) : bool
|
||||
public function checkRequired(Entity $entity, string $field, $validationValue, $data) : bool
|
||||
{
|
||||
if ($this->isNotEmpty($entity, $field)) return true;
|
||||
|
||||
@@ -45,7 +47,7 @@ class EmailType extends BaseType
|
||||
return false;
|
||||
}
|
||||
|
||||
public function checkEmailAddress(\Espo\ORM\Entity $entity, string $field, $validationValue, $data) : bool
|
||||
public function checkEmailAddress(Entity $entity, string $field, $validationValue, $data) : bool
|
||||
{
|
||||
if ($this->isNotEmpty($entity, $field)) {
|
||||
$address = $entity->get($field);
|
||||
@@ -68,7 +70,7 @@ class EmailType extends BaseType
|
||||
return true;
|
||||
}
|
||||
|
||||
protected function isNotEmpty(\Espo\ORM\Entity $entity, $field)
|
||||
protected function isNotEmpty(Entity $entity, $field)
|
||||
{
|
||||
return $entity->has($field) && $entity->get($field) !== '' && $entity->get($field) !== null;
|
||||
}
|
||||
|
||||
@@ -29,14 +29,16 @@
|
||||
|
||||
namespace Espo\Core\FieldValidators;
|
||||
|
||||
use Espo\ORM\Entity;
|
||||
|
||||
class EnumType extends BaseType
|
||||
{
|
||||
public function checkRequired(\Espo\ORM\Entity $entity, string $field, $validationValue, $data) : bool
|
||||
public function checkRequired(Entity $entity, string $field, $validationValue, $data) : bool
|
||||
{
|
||||
return $this->isNotEmpty($entity, $field);
|
||||
}
|
||||
|
||||
protected function isNotEmpty(\Espo\ORM\Entity $entity, $field)
|
||||
protected function isNotEmpty(Entity $entity, $field)
|
||||
{
|
||||
return $entity->has($field) && $entity->get($field) !== null;
|
||||
}
|
||||
|
||||
@@ -29,28 +29,30 @@
|
||||
|
||||
namespace Espo\Core\FieldValidators;
|
||||
|
||||
use Espo\ORM\Entity;
|
||||
|
||||
class IntType extends BaseType
|
||||
{
|
||||
public function checkRequired(\Espo\ORM\Entity $entity, string $field, $validationValue, $data) : bool
|
||||
public function checkRequired(Entity $entity, string $field, $validationValue, $data) : bool
|
||||
{
|
||||
return $this->isNotEmpty($entity, $field);
|
||||
}
|
||||
|
||||
public function checkMax(\Espo\ORM\Entity $entity, string $field, $validationValue, $data) : bool
|
||||
public function checkMax(Entity $entity, string $field, $validationValue, $data) : bool
|
||||
{
|
||||
if (!$this->isNotEmpty($entity, $field)) return true;
|
||||
if ($entity->get($field) > $validationValue) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
public function checkMin(\Espo\ORM\Entity $entity, string $field, $validationValue, $data) : bool
|
||||
public function checkMin(Entity $entity, string $field, $validationValue, $data) : bool
|
||||
{
|
||||
if (!$this->isNotEmpty($entity, $field)) return true;
|
||||
if ($entity->get($field) < $validationValue) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
protected function isNotEmpty(\Espo\ORM\Entity $entity, $field)
|
||||
protected function isNotEmpty(Entity $entity, $field)
|
||||
{
|
||||
return $entity->has($field) && $entity->get($field) !== null;
|
||||
}
|
||||
|
||||
@@ -29,16 +29,18 @@
|
||||
|
||||
namespace Espo\Core\FieldValidators;
|
||||
|
||||
use Espo\ORM\Entity;
|
||||
|
||||
class JsonArrayType extends BaseType
|
||||
{
|
||||
public function checkArray(\Espo\ORM\Entity $entity, string $field, $validationValue, $data) : bool
|
||||
public function checkArray(Entity $entity, string $field, $validationValue, $data) : bool
|
||||
{
|
||||
if (!$entity->has($field) || $entity->get($field) === null) return true;
|
||||
|
||||
return is_array($entity->get($field));
|
||||
}
|
||||
|
||||
protected function isNotEmpty(\Espo\ORM\Entity $entity, $field)
|
||||
protected function isNotEmpty(Entity $entity, $field)
|
||||
{
|
||||
if (!$entity->has($field) || $entity->get($field) === null) return false;
|
||||
$list = $entity->get($field);
|
||||
|
||||
@@ -31,7 +31,7 @@ namespace Espo\Core\FieldValidators;
|
||||
|
||||
class LinkMultipleType extends BaseType
|
||||
{
|
||||
public function checkRequired(\Espo\ORM\Entity $entity, string $field, $validationValue, $data) : bool
|
||||
public function checkRequired(Entity $entity, string $field, $validationValue, $data) : bool
|
||||
{
|
||||
return count($entity->getLinkMultipleIdList($field)) > 0;
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ namespace Espo\Core\FieldValidators;
|
||||
|
||||
class LinkParentType extends BaseType
|
||||
{
|
||||
public function checkRequired(\Espo\ORM\Entity $entity, string $field, $validationValue, $data) : bool
|
||||
public function checkRequired(Entity $entity, string $field, $validationValue, $data) : bool
|
||||
{
|
||||
$idAttribute = $field . 'Id';
|
||||
$typeAttribute = $field . 'Type';
|
||||
|
||||
@@ -31,7 +31,7 @@ namespace Espo\Core\FieldValidators;
|
||||
|
||||
class LinkType extends BaseType
|
||||
{
|
||||
public function checkRequired(\Espo\ORM\Entity $entity, string $field, $validationValue, $data) : bool
|
||||
public function checkRequired(Entity $entity, string $field, $validationValue, $data) : bool
|
||||
{
|
||||
$idAttribute = $field . 'Id';
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ namespace Espo\Core\FieldValidators;
|
||||
|
||||
class PersonNameType extends BaseType
|
||||
{
|
||||
public function checkRequired(\Espo\ORM\Entity $entity, string $field, $validationValue, $data) : bool
|
||||
public function checkRequired(Entity $entity, string $field, $validationValue, $data) : bool
|
||||
{
|
||||
$isEmpty = true;
|
||||
foreach ($this->getActualAttributeList($entity, $field) as $attribute) {
|
||||
|
||||
@@ -29,9 +29,11 @@
|
||||
|
||||
namespace Espo\Core\FieldValidators;
|
||||
|
||||
use Espo\ORM\Entity;
|
||||
|
||||
class PhoneType extends BaseType
|
||||
{
|
||||
public function checkRequired(\Espo\ORM\Entity $entity, string $field, $validationValue, $data) : bool
|
||||
public function checkRequired(Entity $entity, string $field, $validationValue, $data) : bool
|
||||
{
|
||||
if ($this->isNotEmpty($entity, $field)) return true;
|
||||
|
||||
@@ -45,7 +47,7 @@ class PhoneType extends BaseType
|
||||
return false;
|
||||
}
|
||||
|
||||
protected function isNotEmpty(\Espo\ORM\Entity $entity, $field)
|
||||
protected function isNotEmpty(Entity $entity, $field)
|
||||
{
|
||||
return $entity->has($field) && $entity->get($field) !== '' && $entity->get($field) !== null;
|
||||
}
|
||||
|
||||
@@ -29,14 +29,16 @@
|
||||
|
||||
namespace Espo\Core\FieldValidators;
|
||||
|
||||
use Espo\ORM\Entity;
|
||||
|
||||
class VarcharType extends BaseType
|
||||
{
|
||||
public function checkRequired(\Espo\ORM\Entity $entity, string $field, $validationValue, $data) : bool
|
||||
public function checkRequired(Entity $entity, string $field, $validationValue, $data) : bool
|
||||
{
|
||||
return $this->isNotEmpty($entity, $field);
|
||||
}
|
||||
|
||||
public function checkMaxLength(\Espo\ORM\Entity $entity, string $field, $validationValue, $data) : bool
|
||||
public function checkMaxLength(Entity $entity, string $field, $validationValue, $data) : bool
|
||||
{
|
||||
if ($this->isNotEmpty($entity, $field)) {
|
||||
$value = $entity->get($field);
|
||||
@@ -47,7 +49,7 @@ class VarcharType extends BaseType
|
||||
return true;
|
||||
}
|
||||
|
||||
protected function isNotEmpty(\Espo\ORM\Entity $entity, $field)
|
||||
protected function isNotEmpty(Entity $entity, $field)
|
||||
{
|
||||
return $entity->has($field) && $entity->get($field) !== '' && $entity->get($field) !== null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user