diff --git a/src/Entity/Parts/PartLot.php b/src/Entity/Parts/PartLot.php
index e3f0fcef..32db4828 100644
--- a/src/Entity/Parts/PartLot.php
+++ b/src/Entity/Parts/PartLot.php
@@ -343,6 +343,13 @@ class PartLot extends AbstractDBElement implements TimeStampableInterface, Named
*/
public function validate(ExecutionContextInterface $context, $payload)
{
+ //Ensure that the owner is not the anonymous user
+ if ($this->getOwner() && $this->getOwner()->isAnonymousUser()) {
+ $context->buildViolation('validator.part_lot.owner_must_not_be_anonymous')
+ ->atPath('owner')
+ ->addViolation();
+ }
+
//When the storage location sets the owner must match, the part lot owner must match the storage location owner
if ($this->getStorageLocation() && $this->getStorageLocation()->isPartOwnerMustMatch()
&& $this->getStorageLocation()->getOwner() && $this->getOwner()) {
diff --git a/src/Entity/Parts/Storelocation.php b/src/Entity/Parts/Storelocation.php
index 6ea009e2..0d90f96a 100644
--- a/src/Entity/Parts/Storelocation.php
+++ b/src/Entity/Parts/Storelocation.php
@@ -94,6 +94,7 @@ class Storelocation extends AbstractPartsContainingDBElement
* @var User|null The owner of this storage location
* @ORM\ManyToOne(targetEntity="App\Entity\UserSystem\User")
* @ORM\JoinColumn(name="id_owner", referencedColumnName="id", nullable=true, onDelete="SET NULL")
+ * @Assert\Expression("this.getOwner() == null or this.getOwner().isAnonymousUser() === false", message="validator.part_lot.owner_must_not_be_anonymous")
*/
protected ?User $owner = null;
diff --git a/translations/validators.en.xlf b/translations/validators.en.xlf
index 771f3163..1f3438de 100644
--- a/translations/validators.en.xlf
+++ b/translations/validators.en.xlf
@@ -311,5 +311,11 @@
The owner of this lot must match the owner of the selected storage location (%owner_name%)!
+
+
+ validator.part_lot.owner_must_not_be_anonymous
+ A lot owner must not be the anonymous user!
+
+