generated from spatie/package-skeleton-laravel
-
-
Notifications
You must be signed in to change notification settings - Fork 223
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into beyond-data
# Conflicts: # CHANGELOG.md # docs/advanced-usage/validation-attributes.md # docs/as-a-data-transfer-object/creating-a-data-object.md # src/Transformers/DataTransformer.php
- Loading branch information
Showing
16 changed files
with
311 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?php | ||
|
||
namespace Spatie\LaravelData\Attributes\Validation; | ||
|
||
use Attribute; | ||
|
||
#[Attribute(Attribute::TARGET_PROPERTY | Attribute::TARGET_PARAMETER)] | ||
class Declined extends StringValidationAttribute | ||
{ | ||
public static function keyword(): string | ||
{ | ||
return 'declined'; | ||
} | ||
|
||
public function parameters(): array | ||
{ | ||
return []; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?php | ||
|
||
namespace Spatie\LaravelData\Attributes\Validation; | ||
|
||
use Attribute; | ||
use BackedEnum; | ||
use Spatie\LaravelData\Support\Validation\References\FieldReference; | ||
use Spatie\LaravelData\Support\Validation\References\RouteParameterReference; | ||
|
||
#[Attribute(Attribute::TARGET_PROPERTY | Attribute::TARGET_PARAMETER)] | ||
class DeclinedIf extends StringValidationAttribute | ||
{ | ||
protected FieldReference $field; | ||
|
||
public function __construct( | ||
string|FieldReference $field, | ||
protected string|bool|int|float|BackedEnum|RouteParameterReference $value, | ||
) { | ||
$this->field = $this->parseFieldReference($field); | ||
} | ||
|
||
public static function keyword(): string | ||
{ | ||
return 'declined_if'; | ||
} | ||
|
||
public function parameters(): array | ||
{ | ||
return [$this->field, $this->value]; | ||
} | ||
|
||
public static function create(string ...$parameters): static | ||
{ | ||
return parent::create( | ||
$parameters[0], | ||
self::parseBooleanValue($parameters[1]), | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?php | ||
|
||
namespace Spatie\LaravelData\Attributes\Validation; | ||
|
||
use Attribute; | ||
|
||
#[Attribute(Attribute::TARGET_PROPERTY | Attribute::TARGET_PARAMETER)] | ||
class MacAddress extends StringValidationAttribute | ||
{ | ||
public static function keyword(): string | ||
{ | ||
return 'mac_address'; | ||
} | ||
|
||
public function parameters(): array | ||
{ | ||
return []; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?php | ||
|
||
namespace Spatie\LaravelData\Attributes\Validation; | ||
|
||
use Attribute; | ||
use Illuminate\Support\Arr; | ||
use Spatie\LaravelData\Support\Validation\References\RouteParameterReference; | ||
|
||
#[Attribute(Attribute::TARGET_PROPERTY | Attribute::TARGET_PARAMETER)] | ||
class RequiredArrayKeys extends StringValidationAttribute | ||
{ | ||
protected string|array $values; | ||
|
||
public function __construct(string|array|RouteParameterReference ...$values) | ||
{ | ||
$this->values = Arr::flatten($values); | ||
} | ||
|
||
public static function keyword(): string | ||
{ | ||
return 'required_array_keys'; | ||
} | ||
|
||
public function parameters(): array | ||
{ | ||
return [$this->values]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
Oops, something went wrong.