improve customer validation (#2083)
This commit is contained in:
@@ -152,6 +152,7 @@ class Customer implements EntityWithMetaFields
|
||||
*
|
||||
* @ORM\Column(name="country", type="string", length=2, nullable=false)
|
||||
* @Assert\NotBlank()
|
||||
* @Assert\Country()
|
||||
* @Assert\Length(max=2)
|
||||
*/
|
||||
private $country;
|
||||
@@ -165,6 +166,7 @@ class Customer implements EntityWithMetaFields
|
||||
*
|
||||
* @ORM\Column(name="currency", type="string", length=3, nullable=false)
|
||||
* @Assert\NotBlank()
|
||||
* @Assert\Currency()
|
||||
* @Assert\Length(max=3)
|
||||
*/
|
||||
private $currency = self::DEFAULT_CURRENCY;
|
||||
@@ -428,7 +430,7 @@ class Customer implements EntityWithMetaFields
|
||||
return $this->address;
|
||||
}
|
||||
|
||||
public function setCountry(string $country): Customer
|
||||
public function setCountry(?string $country): Customer
|
||||
{
|
||||
$this->country = $country;
|
||||
|
||||
@@ -440,14 +442,14 @@ class Customer implements EntityWithMetaFields
|
||||
return $this->country;
|
||||
}
|
||||
|
||||
public function setCurrency(string $currency): Customer
|
||||
public function setCurrency(?string $currency): Customer
|
||||
{
|
||||
$this->currency = $currency;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getCurrency(): string
|
||||
public function getCurrency(): ?string
|
||||
{
|
||||
return $this->currency;
|
||||
}
|
||||
|
||||
@@ -109,6 +109,12 @@ class CustomerTest extends TestCase
|
||||
|
||||
self::assertInstanceOf(Customer::class, $sut->setVatId('ID 1234567890'));
|
||||
self::assertEquals('ID 1234567890', $sut->getVatId());
|
||||
|
||||
self::assertInstanceOf(Customer::class, $sut->setCountry(null));
|
||||
self::assertNull($sut->getCountry());
|
||||
|
||||
self::assertInstanceOf(Customer::class, $sut->setCurrency(null));
|
||||
self::assertNull($sut->getCurrency());
|
||||
}
|
||||
|
||||
public function testMetaFields()
|
||||
|
||||
Reference in New Issue
Block a user