Skip to content

Commit

Permalink
Swap empty with explicit string comparison.
Browse files Browse the repository at this point in the history
  • Loading branch information
michael-rubel committed Oct 4, 2023
1 parent 7eb268e commit f3accdd
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/Artisan/stubs/value-object.stub
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class {{ class }} extends ValueObject
{
// TODO: Implement validate() method.

if (empty($this->value())) {
if ($this->value() === '') {
throw ValidationException::withMessages(['Value of {{ class }} cannot be empty.']);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Collection/Complex/ClassString.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ public function value(): string
*/
protected function validate(): void
{
if (empty($this->value())) {
if ($this->value() === '') {
throw ValidationException::withMessages(['Class string cannot be empty.']);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Collection/Complex/FullName.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public function toArray(): array
*/
protected function validate(): void
{
if (empty($this->value())) {
if ($this->value() === '') {
throw ValidationException::withMessages(['Full name cannot be empty.']);
}

Expand Down
2 changes: 1 addition & 1 deletion src/Collection/Complex/TaxNumber.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ public function toArray(): array
*/
protected function validate(): void
{
if (empty($this->value())) {
if ($this->value() === '') {
throw ValidationException::withMessages(['Tax number cannot be empty.']);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Collection/Primitive/Text.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public function value(): string
*/
protected function validate(): void
{
if (empty($this->value())) {
if ($this->value() === '') {
throw new InvalidArgumentException('Text cannot be empty.');
}
}
Expand Down

0 comments on commit f3accdd

Please sign in to comment.