Domain Examples :
1.
class Customer {
public $id;
public $purchaseLimitReached = TRUE;
}
class Order {
public $customer;
public function Order(Customer $customer) {
if($customer->purchaseLimitReached === TRUE) {
throw new Exception('Order cannot be created, customer
has reached his limits!');
}
}
}
2.
class User {
public $email;
public $emailOwnershipVerified = FALSE;
}
In case 1, should the rule that an order cannot have as reference a customer that has reached his purchase limit be part of the domain, in the order object? Or should this rule be part of the authorization, that is handled outside the domain?
In case 2, if the User has not veryfied himself (the email), he has no right over any associations/reference in the domain. He cannot authenticate, post, comment, or even view private/hidden data. Should the domain objects have checks that enforce a valid reference/association to a User? Or should the verification that a User has verified himself be part of the authorization, again outside the domain?