Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"require": {
"php": "^8.0",
"illuminate/contracts": "^9.33|^10.0",
"illuminate/validation": "^9.33|^10.0",
"michael-rubel/laravel-formatters": "^7.0.6",
"phpmath/bignumber": "^1.2",
"spatie/laravel-package-tools": "^1.12"
Expand Down
2 changes: 1 addition & 1 deletion src/Artisan/stubs/value-object.stub
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ class {{ class }} extends ValueObject
// TODO: Implement validate() method.

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

if ($validator->fails()) {
throw ValidationException::withMessages([__('Your email is invalid.')]);
throw ValidationException::withMessages(['Your email is invalid.']);
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/Collection/Complex/FullName.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,11 @@ public function toArray(): array
protected function validate(): void
{
if (empty($this->value())) {
throw ValidationException::withMessages([__('Full name cannot be empty.')]);
throw ValidationException::withMessages(['Full name cannot be empty.']);
}

if (count($this->split) < 2) {
throw ValidationException::withMessages([__('Full name should have a first name and last name.')]);
throw ValidationException::withMessages(['Full name should have a first name and last name.']);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/Collection/Complex/Phone.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public function sanitized(): string
protected function validate(): void
{
if (! preg_match('/^[+]?[0-9 ]{5,15}$/', $this->sanitized())) {
throw ValidationException::withMessages([__('Your phone number is invalid.')]);
throw ValidationException::withMessages(['Your phone number is invalid.']);
}
}

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 @@ -142,7 +142,7 @@ public function toArray(): array
protected function validate(): void
{
if (empty($this->value())) {
throw ValidationException::withMessages([__('Tax number cannot be empty.')]);
throw ValidationException::withMessages(['Tax number cannot be empty.']);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/Collection/Complex/Url.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public function __construct(string $value)
);

if ($validator->fails()) {
throw ValidationException::withMessages([__('Your URL is invalid.')]);
throw ValidationException::withMessages(['Your URL is invalid.']);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/Collection/Complex/Uuid.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ public function toArray(): array
protected function validate(): void
{
if (! str($this->value())->isUuid()) {
throw ValidationException::withMessages([__('UUID is invalid.')]);
throw ValidationException::withMessages(['UUID is invalid.']);
}
}
}
2 changes: 1 addition & 1 deletion src/ValueObject.php
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,6 @@ public function __get(string $name): mixed
*/
public function __set(string $name, mixed $value): void
{
throw new InvalidArgumentException(__(static::IMMUTABLE_MESSAGE));
throw new InvalidArgumentException(static::IMMUTABLE_MESSAGE);
}
}
2 changes: 1 addition & 1 deletion tests/Unit/Complex/ClassStringTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
try {
new ClassString('');
} catch (ValidationException $e) {
$this->assertSame(__('Class string cannot be empty.'), $e->getMessage());
$this->assertSame('Class string cannot be empty.', $e->getMessage());
}
});

Expand Down
2 changes: 1 addition & 1 deletion tests/Unit/Complex/EmailTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
try {
new Email('');
} catch (ValidationException $e) {
$this->assertSame(__('Your email is invalid.'), $e->getMessage());
$this->assertSame('Your email is invalid.', $e->getMessage());
}
});

Expand Down
4 changes: 2 additions & 2 deletions tests/Unit/Complex/FullNameTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,13 @@
try {
new FullName('');
} catch (ValidationException $e) {
$this->assertSame(__('Full name cannot be empty.'), $e->getMessage());
$this->assertSame('Full name cannot be empty.', $e->getMessage());
}

try {
new FullName('Test');
} catch (ValidationException $e) {
$this->assertSame(__('Full name should have a first name and last name.'), $e->getMessage());
$this->assertSame('Full name should have a first name and last name.', $e->getMessage());
}
});

Expand Down
2 changes: 1 addition & 1 deletion tests/Unit/Complex/PhoneTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
try {
new Phone('123');
} catch (ValidationException $e) {
$this->assertSame(__('Your phone number is invalid.'), $e->getMessage());
$this->assertSame('Your phone number is invalid.', $e->getMessage());
}
});

Expand Down
2 changes: 1 addition & 1 deletion tests/Unit/Complex/UrlTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ public function __construct(string|Stringable $value)
);

if ($validator->fails()) {
throw ValidationException::withMessages([__('Your URL is invalid.')]);
throw ValidationException::withMessages(['Your URL is invalid.']);
}
}

Expand Down
2 changes: 1 addition & 1 deletion tests/Unit/Complex/UuidTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
try {
new Uuid('123123');
} catch (ValidationException $e) {
$this->assertSame(__('UUID is invalid.'), $e->getMessage());
$this->assertSame('UUID is invalid.', $e->getMessage());
}
});

Expand Down