Open
Description
Description
When you have a complex stmt
UniqueEntity(
fields: ['product', 'supplier', 'validFrom', 'validTill', 'minOrderQty', 'isSale', 'isSpecial'],
message: 'Purchase price ({{ value }}) already exists for the product',
),
it would be great to allow configure value as result of toString
from current class.
Right now if errorPath is not defined, it will use first from criteria, if defined it will use only that "path" value.
Idea:
Create flag that will indicate to use toString
of current class, it will allow set value
of all values that current class has and will help to find/understand why current entity has failed.
Example
UniqueEntity(
fields: ['product', 'supplier', 'validFrom', 'validTill', 'minOrderQty', 'isSale', 'isSpecial'],
message: 'Purchase price ({{ value }}) already exists for the product',
),
public function __toString(): string
{
return sprintf(
'#%d, %s, Supplier: %s, Value: %s (%s to %s), MOQ: %s, Sale: %b, Special: %b',
$this->id,
$this->product?->getGtin(),
$this->supplier?->getName(),
$this->value,
$this->validFrom?->format('Y-m-d') ?? '',
$this->validTill?->format('Y-m-d') ?? '',
$this->minOrderQty,
$this->isSale,
$this->isSpecial,
);
}
Expected result:
Purchase price (ID, GTIN, SUPPLIER, VALUE, VALID FROM VALID TILL MOQ SALE SPECIAL) already exists for the product