diff --git a/src/Attributes/Validation/Accepted.php b/src/Attributes/Validation/Accepted.php index 3894909b..21b52654 100644 --- a/src/Attributes/Validation/Accepted.php +++ b/src/Attributes/Validation/Accepted.php @@ -4,7 +4,7 @@ use Attribute; -#[Attribute(Attribute::TARGET_PROPERTY)] +#[Attribute(Attribute::TARGET_PROPERTY | Attribute::TARGET_PARAMETER)] class Accepted extends StringValidationAttribute { public static function keyword(): string diff --git a/src/Attributes/Validation/AcceptedIf.php b/src/Attributes/Validation/AcceptedIf.php index 05411231..4a88e0ba 100644 --- a/src/Attributes/Validation/AcceptedIf.php +++ b/src/Attributes/Validation/AcceptedIf.php @@ -7,7 +7,7 @@ use Spatie\LaravelData\Support\Validation\References\FieldReference; use Spatie\LaravelData\Support\Validation\References\RouteParameterReference; -#[Attribute(Attribute::TARGET_PROPERTY)] +#[Attribute(Attribute::TARGET_PROPERTY | Attribute::TARGET_PARAMETER)] class AcceptedIf extends StringValidationAttribute { protected FieldReference $field; diff --git a/src/Attributes/Validation/ActiveUrl.php b/src/Attributes/Validation/ActiveUrl.php index 4987dda4..0186a183 100644 --- a/src/Attributes/Validation/ActiveUrl.php +++ b/src/Attributes/Validation/ActiveUrl.php @@ -4,7 +4,7 @@ use Attribute; -#[Attribute(Attribute::TARGET_PROPERTY)] +#[Attribute(Attribute::TARGET_PROPERTY | Attribute::TARGET_PARAMETER)] class ActiveUrl extends StringValidationAttribute { public static function keyword(): string diff --git a/src/Attributes/Validation/After.php b/src/Attributes/Validation/After.php index 9c60f91e..ee6c0b0f 100644 --- a/src/Attributes/Validation/After.php +++ b/src/Attributes/Validation/After.php @@ -6,7 +6,7 @@ use DateTimeInterface; use Spatie\LaravelData\Support\Validation\References\FieldReference; -#[Attribute(Attribute::TARGET_PROPERTY)] +#[Attribute(Attribute::TARGET_PROPERTY | Attribute::TARGET_PARAMETER)] class After extends StringValidationAttribute { public function __construct(protected string|DateTimeInterface|FieldReference $date) diff --git a/src/Attributes/Validation/AfterOrEqual.php b/src/Attributes/Validation/AfterOrEqual.php index 1865ca94..6f302b57 100644 --- a/src/Attributes/Validation/AfterOrEqual.php +++ b/src/Attributes/Validation/AfterOrEqual.php @@ -6,7 +6,7 @@ use DateTimeInterface; use Spatie\LaravelData\Support\Validation\References\RouteParameterReference; -#[Attribute(Attribute::TARGET_PROPERTY)] +#[Attribute(Attribute::TARGET_PROPERTY | Attribute::TARGET_PARAMETER)] class AfterOrEqual extends StringValidationAttribute { public function __construct(protected string|DateTimeInterface|RouteParameterReference $date) diff --git a/src/Attributes/Validation/Alpha.php b/src/Attributes/Validation/Alpha.php index 10e97d7e..1a4ce809 100644 --- a/src/Attributes/Validation/Alpha.php +++ b/src/Attributes/Validation/Alpha.php @@ -4,7 +4,7 @@ use Attribute; -#[Attribute(Attribute::TARGET_PROPERTY)] +#[Attribute(Attribute::TARGET_PROPERTY | Attribute::TARGET_PARAMETER)] class Alpha extends StringValidationAttribute { public static function keyword(): string diff --git a/src/Attributes/Validation/AlphaDash.php b/src/Attributes/Validation/AlphaDash.php index 1e3afdcd..d46d5aed 100644 --- a/src/Attributes/Validation/AlphaDash.php +++ b/src/Attributes/Validation/AlphaDash.php @@ -4,7 +4,7 @@ use Attribute; -#[Attribute(Attribute::TARGET_PROPERTY)] +#[Attribute(Attribute::TARGET_PROPERTY | Attribute::TARGET_PARAMETER)] class AlphaDash extends StringValidationAttribute { public static function keyword(): string diff --git a/src/Attributes/Validation/AlphaNumeric.php b/src/Attributes/Validation/AlphaNumeric.php index c86cbfd4..1a2091db 100644 --- a/src/Attributes/Validation/AlphaNumeric.php +++ b/src/Attributes/Validation/AlphaNumeric.php @@ -4,7 +4,7 @@ use Attribute; -#[Attribute(Attribute::TARGET_PROPERTY)] +#[Attribute(Attribute::TARGET_PROPERTY | Attribute::TARGET_PARAMETER)] class AlphaNumeric extends StringValidationAttribute { public static function keyword(): string diff --git a/src/Attributes/Validation/ArrayType.php b/src/Attributes/Validation/ArrayType.php index 22c24f3f..06337caf 100644 --- a/src/Attributes/Validation/ArrayType.php +++ b/src/Attributes/Validation/ArrayType.php @@ -6,7 +6,7 @@ use Illuminate\Support\Arr; use Spatie\LaravelData\Support\Validation\References\RouteParameterReference; -#[Attribute(Attribute::TARGET_PROPERTY)] +#[Attribute(Attribute::TARGET_PROPERTY | Attribute::TARGET_PARAMETER)] class ArrayType extends StringValidationAttribute { protected array $keys; diff --git a/src/Attributes/Validation/Bail.php b/src/Attributes/Validation/Bail.php index f8288087..4d504de9 100644 --- a/src/Attributes/Validation/Bail.php +++ b/src/Attributes/Validation/Bail.php @@ -4,7 +4,7 @@ use Attribute; -#[Attribute(Attribute::TARGET_PROPERTY)] +#[Attribute(Attribute::TARGET_PROPERTY | Attribute::TARGET_PARAMETER)] class Bail extends StringValidationAttribute { public static function keyword(): string diff --git a/src/Attributes/Validation/Before.php b/src/Attributes/Validation/Before.php index ca049c7a..11366abd 100644 --- a/src/Attributes/Validation/Before.php +++ b/src/Attributes/Validation/Before.php @@ -7,7 +7,7 @@ use Spatie\LaravelData\Support\Validation\References\FieldReference; use Spatie\LaravelData\Support\Validation\References\RouteParameterReference; -#[Attribute(Attribute::TARGET_PROPERTY)] +#[Attribute(Attribute::TARGET_PROPERTY | Attribute::TARGET_PARAMETER)] class Before extends StringValidationAttribute { public function __construct(protected string|DateTimeInterface|RouteParameterReference|FieldReference $date) diff --git a/src/Attributes/Validation/BeforeOrEqual.php b/src/Attributes/Validation/BeforeOrEqual.php index 6751f4ce..700047a6 100644 --- a/src/Attributes/Validation/BeforeOrEqual.php +++ b/src/Attributes/Validation/BeforeOrEqual.php @@ -6,7 +6,7 @@ use DateTimeInterface; use Spatie\LaravelData\Support\Validation\References\RouteParameterReference; -#[Attribute(Attribute::TARGET_PROPERTY)] +#[Attribute(Attribute::TARGET_PROPERTY | Attribute::TARGET_PARAMETER)] class BeforeOrEqual extends StringValidationAttribute { public function __construct(protected string | DateTimeInterface|RouteParameterReference $date) diff --git a/src/Attributes/Validation/Between.php b/src/Attributes/Validation/Between.php index 329361c3..1b45766a 100644 --- a/src/Attributes/Validation/Between.php +++ b/src/Attributes/Validation/Between.php @@ -5,7 +5,7 @@ use Attribute; use Spatie\LaravelData\Support\Validation\References\RouteParameterReference; -#[Attribute(Attribute::TARGET_PROPERTY)] +#[Attribute(Attribute::TARGET_PROPERTY | Attribute::TARGET_PARAMETER)] class Between extends StringValidationAttribute { public function __construct(protected int|float|RouteParameterReference $min, protected int|float|RouteParameterReference $max) diff --git a/src/Attributes/Validation/BooleanType.php b/src/Attributes/Validation/BooleanType.php index 0c1f2fc2..40e42619 100644 --- a/src/Attributes/Validation/BooleanType.php +++ b/src/Attributes/Validation/BooleanType.php @@ -4,7 +4,7 @@ use Attribute; -#[Attribute(Attribute::TARGET_PROPERTY)] +#[Attribute(Attribute::TARGET_PROPERTY | Attribute::TARGET_PARAMETER)] class BooleanType extends StringValidationAttribute { public static function keyword(): string diff --git a/src/Attributes/Validation/Confirmed.php b/src/Attributes/Validation/Confirmed.php index a032c9da..4c5e4117 100644 --- a/src/Attributes/Validation/Confirmed.php +++ b/src/Attributes/Validation/Confirmed.php @@ -4,7 +4,7 @@ use Attribute; -#[Attribute(Attribute::TARGET_PROPERTY)] +#[Attribute(Attribute::TARGET_PROPERTY | Attribute::TARGET_PARAMETER)] class Confirmed extends StringValidationAttribute { public static function keyword(): string diff --git a/src/Attributes/Validation/CurrentPassword.php b/src/Attributes/Validation/CurrentPassword.php index 03b42d19..a8b7b9cb 100644 --- a/src/Attributes/Validation/CurrentPassword.php +++ b/src/Attributes/Validation/CurrentPassword.php @@ -6,7 +6,7 @@ use Spatie\LaravelData\Support\Validation\References\RouteParameterReference; use Spatie\LaravelData\Tests\Fakes\Enums\DummyBackedEnum; -#[Attribute(Attribute::TARGET_PROPERTY)] +#[Attribute(Attribute::TARGET_PROPERTY | Attribute::TARGET_PARAMETER)] class CurrentPassword extends StringValidationAttribute { public function __construct(protected null|string|DummyBackedEnum|RouteParameterReference $guard = null) diff --git a/src/Attributes/Validation/Date.php b/src/Attributes/Validation/Date.php index b8ca815e..b1074ffc 100644 --- a/src/Attributes/Validation/Date.php +++ b/src/Attributes/Validation/Date.php @@ -4,7 +4,7 @@ use Attribute; -#[Attribute(Attribute::TARGET_PROPERTY)] +#[Attribute(Attribute::TARGET_PROPERTY | Attribute::TARGET_PARAMETER)] class Date extends StringValidationAttribute { public static function keyword(): string diff --git a/src/Attributes/Validation/DateEquals.php b/src/Attributes/Validation/DateEquals.php index 6f239f39..43001539 100644 --- a/src/Attributes/Validation/DateEquals.php +++ b/src/Attributes/Validation/DateEquals.php @@ -6,10 +6,10 @@ use DateTimeInterface; use Spatie\LaravelData\Support\Validation\References\RouteParameterReference; -#[Attribute(Attribute::TARGET_PROPERTY)] +#[Attribute(Attribute::TARGET_PROPERTY | Attribute::TARGET_PARAMETER)] class DateEquals extends StringValidationAttribute { - public function __construct(protected string | DateTimeInterface|RouteParameterReference $date) + public function __construct(protected string|DateTimeInterface|RouteParameterReference $date) { } diff --git a/src/Attributes/Validation/DateFormat.php b/src/Attributes/Validation/DateFormat.php index ac18d8db..e6228774 100644 --- a/src/Attributes/Validation/DateFormat.php +++ b/src/Attributes/Validation/DateFormat.php @@ -4,7 +4,7 @@ use Attribute; -#[Attribute(Attribute::TARGET_PROPERTY)] +#[Attribute(Attribute::TARGET_PROPERTY | Attribute::TARGET_PARAMETER)] class DateFormat extends StringValidationAttribute { public function __construct(protected string $format) diff --git a/src/Attributes/Validation/Different.php b/src/Attributes/Validation/Different.php index 941cb696..3c80fa2b 100644 --- a/src/Attributes/Validation/Different.php +++ b/src/Attributes/Validation/Different.php @@ -5,7 +5,7 @@ use Attribute; use Spatie\LaravelData\Support\Validation\References\FieldReference; -#[Attribute(Attribute::TARGET_PROPERTY)] +#[Attribute(Attribute::TARGET_PROPERTY | Attribute::TARGET_PARAMETER)] class Different extends StringValidationAttribute { protected FieldReference $field; diff --git a/src/Attributes/Validation/Digits.php b/src/Attributes/Validation/Digits.php index cd79b507..66130096 100644 --- a/src/Attributes/Validation/Digits.php +++ b/src/Attributes/Validation/Digits.php @@ -5,7 +5,7 @@ use Attribute; use Spatie\LaravelData\Support\Validation\References\RouteParameterReference; -#[Attribute(Attribute::TARGET_PROPERTY)] +#[Attribute(Attribute::TARGET_PROPERTY | Attribute::TARGET_PARAMETER)] class Digits extends StringValidationAttribute { public function __construct(protected int|RouteParameterReference $value) diff --git a/src/Attributes/Validation/DigitsBetween.php b/src/Attributes/Validation/DigitsBetween.php index 2de51f6f..9fbe13f8 100644 --- a/src/Attributes/Validation/DigitsBetween.php +++ b/src/Attributes/Validation/DigitsBetween.php @@ -5,7 +5,7 @@ use Attribute; use Spatie\LaravelData\Support\Validation\References\RouteParameterReference; -#[Attribute(Attribute::TARGET_PROPERTY)] +#[Attribute(Attribute::TARGET_PROPERTY | Attribute::TARGET_PARAMETER)] class DigitsBetween extends StringValidationAttribute { public function __construct(protected int|RouteParameterReference $min, protected int|RouteParameterReference $max) diff --git a/src/Attributes/Validation/Dimensions.php b/src/Attributes/Validation/Dimensions.php index 42b2f0a7..b20326c1 100644 --- a/src/Attributes/Validation/Dimensions.php +++ b/src/Attributes/Validation/Dimensions.php @@ -9,21 +9,22 @@ use Spatie\LaravelData\Support\Validation\References\RouteParameterReference; use Spatie\LaravelData\Support\Validation\ValidationPath; -#[Attribute(Attribute::TARGET_PROPERTY)] +#[Attribute(Attribute::TARGET_PROPERTY | Attribute::TARGET_PARAMETER)] class Dimensions extends ObjectValidationAttribute { protected BaseDimensions $rule; public function __construct( - null|int|RouteParameterReference $minWidth = null, - null|int|RouteParameterReference $minHeight = null, - null|int|RouteParameterReference $maxWidth = null, - null|int|RouteParameterReference $maxHeight = null, + null|int|RouteParameterReference $minWidth = null, + null|int|RouteParameterReference $minHeight = null, + null|int|RouteParameterReference $maxWidth = null, + null|int|RouteParameterReference $maxHeight = null, null|float|string|RouteParameterReference $ratio = null, - null|int|RouteParameterReference $width = null, - null|int|RouteParameterReference $height = null, - null|BaseDimensions $rule = null, - ) { + null|int|RouteParameterReference $width = null, + null|int|RouteParameterReference $height = null, + null|BaseDimensions $rule = null, + ) + { $minWidth = $this->normalizePossibleRouteReferenceParameter($minWidth); $minHeight = $this->normalizePossibleRouteReferenceParameter($minHeight); $maxWidth = $this->normalizePossibleRouteReferenceParameter($maxWidth); diff --git a/src/Attributes/Validation/Distinct.php b/src/Attributes/Validation/Distinct.php index 3e9002e9..0f294cd9 100644 --- a/src/Attributes/Validation/Distinct.php +++ b/src/Attributes/Validation/Distinct.php @@ -6,7 +6,7 @@ use Spatie\LaravelData\Exceptions\CannotBuildValidationRule; use Spatie\LaravelData\Support\Validation\References\RouteParameterReference; -#[Attribute(Attribute::TARGET_PROPERTY)] +#[Attribute(Attribute::TARGET_PROPERTY | Attribute::TARGET_PARAMETER)] class Distinct extends StringValidationAttribute { public const Strict = 'strict'; diff --git a/src/Attributes/Validation/Email.php b/src/Attributes/Validation/Email.php index 4a054588..31be6cf1 100644 --- a/src/Attributes/Validation/Email.php +++ b/src/Attributes/Validation/Email.php @@ -8,7 +8,7 @@ use Spatie\LaravelData\Exceptions\CannotBuildValidationRule; use Spatie\LaravelData\Support\Validation\References\RouteParameterReference; -#[Attribute(Attribute::TARGET_PROPERTY)] +#[Attribute(Attribute::TARGET_PROPERTY | Attribute::TARGET_PARAMETER)] class Email extends StringValidationAttribute { public const RfcValidation = 'rfc'; @@ -32,15 +32,15 @@ public static function keyword(): string public function parameters(): array { return collect($this->modes) - ->whenEmpty(fn (Collection $modes) => $modes->add(self::RfcValidation)) - ->filter(fn (string $mode) => in_array($mode, [ + ->whenEmpty(fn(Collection $modes) => $modes->add(self::RfcValidation)) + ->filter(fn(string $mode) => in_array($mode, [ self::RfcValidation, self::NoRfcWarningsValidation, self::DnsCheckValidation, self::SpoofCheckValidation, self::FilterEmailValidation, ])) - ->whenEmpty(fn () => throw CannotBuildValidationRule::create("Email validation rule needs at least one valid mode.")) + ->whenEmpty(fn() => throw CannotBuildValidationRule::create("Email validation rule needs at least one valid mode.")) ->all(); } } diff --git a/src/Attributes/Validation/EndsWith.php b/src/Attributes/Validation/EndsWith.php index 59462c8b..31313cfa 100644 --- a/src/Attributes/Validation/EndsWith.php +++ b/src/Attributes/Validation/EndsWith.php @@ -6,7 +6,7 @@ use Illuminate\Support\Arr; use Spatie\LaravelData\Support\Validation\References\RouteParameterReference; -#[Attribute(Attribute::TARGET_PROPERTY)] +#[Attribute(Attribute::TARGET_PROPERTY | Attribute::TARGET_PARAMETER)] class EndsWith extends StringValidationAttribute { protected string|array $values; diff --git a/src/Attributes/Validation/Enum.php b/src/Attributes/Validation/Enum.php index 5be5ad10..9bef9f6a 100644 --- a/src/Attributes/Validation/Enum.php +++ b/src/Attributes/Validation/Enum.php @@ -7,7 +7,7 @@ use Spatie\LaravelData\Support\Validation\References\RouteParameterReference; use Spatie\LaravelData\Support\Validation\ValidationPath; -#[Attribute(Attribute::TARGET_PROPERTY)] +#[Attribute(Attribute::TARGET_PROPERTY | Attribute::TARGET_PARAMETER)] class Enum extends ObjectValidationAttribute { protected EnumRule $rule; @@ -16,7 +16,7 @@ public function __construct(string|EnumRule|RouteParameterReference $enum) { $this->rule = $enum instanceof EnumRule ? $enum - : new EnumRule((string) $enum); + : new EnumRule((string)$enum); } public static function keyword(): string diff --git a/src/Attributes/Validation/Exclude.php b/src/Attributes/Validation/Exclude.php index 3fb0c300..15cf1276 100644 --- a/src/Attributes/Validation/Exclude.php +++ b/src/Attributes/Validation/Exclude.php @@ -6,7 +6,7 @@ use Illuminate\Validation\Rules\ExcludeIf; use Spatie\LaravelData\Support\Validation\ValidationPath; -#[Attribute(Attribute::TARGET_PROPERTY)] +#[Attribute(Attribute::TARGET_PROPERTY | Attribute::TARGET_PARAMETER)] class Exclude extends ObjectValidationAttribute { public function __construct(protected ExcludeIf $rule) diff --git a/src/Attributes/Validation/ExcludeIf.php b/src/Attributes/Validation/ExcludeIf.php index 249006c7..bba48e5b 100644 --- a/src/Attributes/Validation/ExcludeIf.php +++ b/src/Attributes/Validation/ExcludeIf.php @@ -7,15 +7,16 @@ use Spatie\LaravelData\Support\Validation\References\FieldReference; use Spatie\LaravelData\Support\Validation\References\RouteParameterReference; -#[Attribute(Attribute::TARGET_PROPERTY)] +#[Attribute(Attribute::TARGET_PROPERTY | Attribute::TARGET_PARAMETER)] class ExcludeIf extends StringValidationAttribute { protected FieldReference $field; public function __construct( - string|FieldReference $field, + string|FieldReference $field, protected string|int|float|bool|BackedEnum|RouteParameterReference $value - ) { + ) + { $this->field = $this->parseFieldReference($field); } diff --git a/src/Attributes/Validation/ExcludeUnless.php b/src/Attributes/Validation/ExcludeUnless.php index 3603a6fa..304a86f3 100644 --- a/src/Attributes/Validation/ExcludeUnless.php +++ b/src/Attributes/Validation/ExcludeUnless.php @@ -7,15 +7,16 @@ use Spatie\LaravelData\Support\Validation\References\FieldReference; use Spatie\LaravelData\Support\Validation\References\RouteParameterReference; -#[Attribute(Attribute::TARGET_PROPERTY)] +#[Attribute(Attribute::TARGET_PROPERTY | Attribute::TARGET_PARAMETER)] class ExcludeUnless extends StringValidationAttribute { protected FieldReference $field; public function __construct( - string|FieldReference $field, + string|FieldReference $field, protected string|int|float|bool|BackedEnum|RouteParameterReference $value - ) { + ) + { $this->field = $this->parseFieldReference($field); } diff --git a/src/Attributes/Validation/ExcludeWithout.php b/src/Attributes/Validation/ExcludeWithout.php index 2cfee1c5..8abb0c73 100644 --- a/src/Attributes/Validation/ExcludeWithout.php +++ b/src/Attributes/Validation/ExcludeWithout.php @@ -5,14 +5,15 @@ use Attribute; use Spatie\LaravelData\Support\Validation\References\FieldReference; -#[Attribute(Attribute::TARGET_PROPERTY)] +#[Attribute(Attribute::TARGET_PROPERTY | Attribute::TARGET_PARAMETER)] class ExcludeWithout extends StringValidationAttribute { protected FieldReference $field; public function __construct( string|FieldReference $field, - ) { + ) + { $this->field = $this->parseFieldReference($field); } diff --git a/src/Attributes/Validation/Exists.php b/src/Attributes/Validation/Exists.php index 424826ab..4d744f78 100644 --- a/src/Attributes/Validation/Exists.php +++ b/src/Attributes/Validation/Exists.php @@ -9,7 +9,7 @@ use Spatie\LaravelData\Support\Validation\References\RouteParameterReference; use Spatie\LaravelData\Support\Validation\ValidationPath; -#[Attribute(Attribute::TARGET_PROPERTY)] +#[Attribute(Attribute::TARGET_PROPERTY | Attribute::TARGET_PARAMETER)] class Exists extends ObjectValidationAttribute { protected BaseExists $rule; diff --git a/src/Attributes/Validation/File.php b/src/Attributes/Validation/File.php index 6c2ed45f..14eb8c84 100644 --- a/src/Attributes/Validation/File.php +++ b/src/Attributes/Validation/File.php @@ -4,7 +4,7 @@ use Attribute; -#[Attribute(Attribute::TARGET_PROPERTY)] +#[Attribute(Attribute::TARGET_PROPERTY | Attribute::TARGET_PARAMETER)] class File extends StringValidationAttribute { public static function keyword(): string diff --git a/src/Attributes/Validation/Filled.php b/src/Attributes/Validation/Filled.php index ea0fd36e..599d2dd5 100644 --- a/src/Attributes/Validation/Filled.php +++ b/src/Attributes/Validation/Filled.php @@ -4,7 +4,7 @@ use Attribute; -#[Attribute(Attribute::TARGET_PROPERTY)] +#[Attribute(Attribute::TARGET_PROPERTY | Attribute::TARGET_PARAMETER)] class Filled extends StringValidationAttribute { public static function keyword(): string diff --git a/src/Attributes/Validation/GreaterThan.php b/src/Attributes/Validation/GreaterThan.php index 31a9d3b2..388cdf67 100644 --- a/src/Attributes/Validation/GreaterThan.php +++ b/src/Attributes/Validation/GreaterThan.php @@ -5,7 +5,7 @@ use Attribute; use Spatie\LaravelData\Support\Validation\References\FieldReference; -#[Attribute(Attribute::TARGET_PROPERTY)] +#[Attribute(Attribute::TARGET_PROPERTY | Attribute::TARGET_PARAMETER)] class GreaterThan extends StringValidationAttribute { protected FieldReference $field; diff --git a/src/Attributes/Validation/GreaterThanOrEqualTo.php b/src/Attributes/Validation/GreaterThanOrEqualTo.php index 3a78ff4e..3dc92eba 100644 --- a/src/Attributes/Validation/GreaterThanOrEqualTo.php +++ b/src/Attributes/Validation/GreaterThanOrEqualTo.php @@ -5,7 +5,7 @@ use Attribute; use Spatie\LaravelData\Support\Validation\References\FieldReference; -#[Attribute(Attribute::TARGET_PROPERTY)] +#[Attribute(Attribute::TARGET_PROPERTY | Attribute::TARGET_PARAMETER)] class GreaterThanOrEqualTo extends StringValidationAttribute { protected FieldReference $field; diff --git a/src/Attributes/Validation/IP.php b/src/Attributes/Validation/IP.php index 3e3f7cab..28b7f240 100644 --- a/src/Attributes/Validation/IP.php +++ b/src/Attributes/Validation/IP.php @@ -4,7 +4,7 @@ use Attribute; -#[Attribute(Attribute::TARGET_PROPERTY)] +#[Attribute(Attribute::TARGET_PROPERTY | Attribute::TARGET_PARAMETER)] class IP extends StringValidationAttribute { public static function keyword(): string diff --git a/src/Attributes/Validation/IPv4.php b/src/Attributes/Validation/IPv4.php index d1138a84..371af3df 100644 --- a/src/Attributes/Validation/IPv4.php +++ b/src/Attributes/Validation/IPv4.php @@ -4,7 +4,7 @@ use Attribute; -#[Attribute(Attribute::TARGET_PROPERTY)] +#[Attribute(Attribute::TARGET_PROPERTY | Attribute::TARGET_PARAMETER)] class IPv4 extends StringValidationAttribute { public static function keyword(): string diff --git a/src/Attributes/Validation/IPv6.php b/src/Attributes/Validation/IPv6.php index 313b1af6..ab04a1d3 100644 --- a/src/Attributes/Validation/IPv6.php +++ b/src/Attributes/Validation/IPv6.php @@ -4,7 +4,7 @@ use Attribute; -#[Attribute(Attribute::TARGET_PROPERTY)] +#[Attribute(Attribute::TARGET_PROPERTY | Attribute::TARGET_PARAMETER)] class IPv6 extends StringValidationAttribute { public static function keyword(): string diff --git a/src/Attributes/Validation/Image.php b/src/Attributes/Validation/Image.php index c5ec3fe8..f3971226 100644 --- a/src/Attributes/Validation/Image.php +++ b/src/Attributes/Validation/Image.php @@ -4,7 +4,7 @@ use Attribute; -#[Attribute(Attribute::TARGET_PROPERTY)] +#[Attribute(Attribute::TARGET_PROPERTY | Attribute::TARGET_PARAMETER)] class Image extends StringValidationAttribute { public static function keyword(): string diff --git a/src/Attributes/Validation/In.php b/src/Attributes/Validation/In.php index 53ca5531..81f74d72 100644 --- a/src/Attributes/Validation/In.php +++ b/src/Attributes/Validation/In.php @@ -8,7 +8,7 @@ use Spatie\LaravelData\Support\Validation\References\RouteParameterReference; use Spatie\LaravelData\Support\Validation\ValidationPath; -#[Attribute(Attribute::TARGET_PROPERTY)] +#[Attribute(Attribute::TARGET_PROPERTY | Attribute::TARGET_PARAMETER)] class In extends ObjectValidationAttribute { protected BaseIn $rule; diff --git a/src/Attributes/Validation/InArray.php b/src/Attributes/Validation/InArray.php index 37f105cc..33c4b86e 100644 --- a/src/Attributes/Validation/InArray.php +++ b/src/Attributes/Validation/InArray.php @@ -5,14 +5,15 @@ use Attribute; use Spatie\LaravelData\Support\Validation\References\FieldReference; -#[Attribute(Attribute::TARGET_PROPERTY)] +#[Attribute(Attribute::TARGET_PROPERTY | Attribute::TARGET_PARAMETER)] class InArray extends StringValidationAttribute { protected FieldReference $field; public function __construct( string|FieldReference $field, - ) { + ) + { $this->field = $this->parseFieldReference($field); } diff --git a/src/Attributes/Validation/IntegerType.php b/src/Attributes/Validation/IntegerType.php index 74ccaae7..03c89ce0 100644 --- a/src/Attributes/Validation/IntegerType.php +++ b/src/Attributes/Validation/IntegerType.php @@ -4,7 +4,7 @@ use Attribute; -#[Attribute(Attribute::TARGET_PROPERTY)] +#[Attribute(Attribute::TARGET_PROPERTY | Attribute::TARGET_PARAMETER)] class IntegerType extends StringValidationAttribute { public static function keyword(): string diff --git a/src/Attributes/Validation/Json.php b/src/Attributes/Validation/Json.php index d42afb17..9c1725fc 100644 --- a/src/Attributes/Validation/Json.php +++ b/src/Attributes/Validation/Json.php @@ -4,7 +4,7 @@ use Attribute; -#[Attribute(Attribute::TARGET_PROPERTY)] +#[Attribute(Attribute::TARGET_PROPERTY | Attribute::TARGET_PARAMETER)] class Json extends StringValidationAttribute { public static function keyword(): string diff --git a/src/Attributes/Validation/LessThan.php b/src/Attributes/Validation/LessThan.php index 5ba17b34..67c40c76 100644 --- a/src/Attributes/Validation/LessThan.php +++ b/src/Attributes/Validation/LessThan.php @@ -5,14 +5,15 @@ use Attribute; use Spatie\LaravelData\Support\Validation\References\FieldReference; -#[Attribute(Attribute::TARGET_PROPERTY)] +#[Attribute(Attribute::TARGET_PROPERTY | Attribute::TARGET_PARAMETER)] class LessThan extends StringValidationAttribute { protected FieldReference $field; public function __construct( string|FieldReference $field, - ) { + ) + { $this->field = $this->parseFieldReference($field); } diff --git a/src/Attributes/Validation/LessThanOrEqualTo.php b/src/Attributes/Validation/LessThanOrEqualTo.php index ebd1e670..bc4ef6b4 100644 --- a/src/Attributes/Validation/LessThanOrEqualTo.php +++ b/src/Attributes/Validation/LessThanOrEqualTo.php @@ -5,14 +5,15 @@ use Attribute; use Spatie\LaravelData\Support\Validation\References\FieldReference; -#[Attribute(Attribute::TARGET_PROPERTY)] +#[Attribute(Attribute::TARGET_PROPERTY | Attribute::TARGET_PARAMETER)] class LessThanOrEqualTo extends StringValidationAttribute { protected FieldReference $field; public function __construct( string|FieldReference $field, - ) { + ) + { $this->field = $this->parseFieldReference($field); } diff --git a/src/Attributes/Validation/Max.php b/src/Attributes/Validation/Max.php index 71d17795..364ed3c8 100644 --- a/src/Attributes/Validation/Max.php +++ b/src/Attributes/Validation/Max.php @@ -5,7 +5,7 @@ use Attribute; use Spatie\LaravelData\Support\Validation\References\RouteParameterReference; -#[Attribute(Attribute::TARGET_PROPERTY)] +#[Attribute(Attribute::TARGET_PROPERTY | Attribute::TARGET_PARAMETER)] class Max extends StringValidationAttribute { public function __construct(protected int|RouteParameterReference $value) diff --git a/src/Attributes/Validation/MimeTypes.php b/src/Attributes/Validation/MimeTypes.php index e05aaf17..1da693c6 100644 --- a/src/Attributes/Validation/MimeTypes.php +++ b/src/Attributes/Validation/MimeTypes.php @@ -6,7 +6,7 @@ use Illuminate\Support\Arr; use Spatie\LaravelData\Support\Validation\References\RouteParameterReference; -#[Attribute(Attribute::TARGET_PROPERTY)] +#[Attribute(Attribute::TARGET_PROPERTY | Attribute::TARGET_PARAMETER)] class MimeTypes extends StringValidationAttribute { protected array $mimeTypes; diff --git a/src/Attributes/Validation/Mimes.php b/src/Attributes/Validation/Mimes.php index 8d568d3e..66a36f0f 100644 --- a/src/Attributes/Validation/Mimes.php +++ b/src/Attributes/Validation/Mimes.php @@ -6,7 +6,7 @@ use Illuminate\Support\Arr; use Spatie\LaravelData\Support\Validation\References\RouteParameterReference; -#[Attribute(Attribute::TARGET_PROPERTY)] +#[Attribute(Attribute::TARGET_PROPERTY | Attribute::TARGET_PARAMETER)] class Mimes extends StringValidationAttribute { protected array $mimes; diff --git a/src/Attributes/Validation/Min.php b/src/Attributes/Validation/Min.php index f1684a46..c9f91eff 100644 --- a/src/Attributes/Validation/Min.php +++ b/src/Attributes/Validation/Min.php @@ -5,7 +5,7 @@ use Attribute; use Spatie\LaravelData\Support\Validation\References\RouteParameterReference; -#[Attribute(Attribute::TARGET_PROPERTY)] +#[Attribute(Attribute::TARGET_PROPERTY | Attribute::TARGET_PARAMETER)] class Min extends StringValidationAttribute { public function __construct(protected int|RouteParameterReference $value) diff --git a/src/Attributes/Validation/MultipleOf.php b/src/Attributes/Validation/MultipleOf.php index 0b29b2ea..86025edc 100644 --- a/src/Attributes/Validation/MultipleOf.php +++ b/src/Attributes/Validation/MultipleOf.php @@ -5,7 +5,7 @@ use Attribute; use Spatie\LaravelData\Support\Validation\References\RouteParameterReference; -#[Attribute(Attribute::TARGET_PROPERTY)] +#[Attribute(Attribute::TARGET_PROPERTY | Attribute::TARGET_PARAMETER)] class MultipleOf extends StringValidationAttribute { public function __construct(protected int|float|RouteParameterReference $value) diff --git a/src/Attributes/Validation/NotIn.php b/src/Attributes/Validation/NotIn.php index 2ac0c7cb..4b935862 100644 --- a/src/Attributes/Validation/NotIn.php +++ b/src/Attributes/Validation/NotIn.php @@ -8,7 +8,7 @@ use Spatie\LaravelData\Support\Validation\References\RouteParameterReference; use Spatie\LaravelData\Support\Validation\ValidationPath; -#[Attribute(Attribute::TARGET_PROPERTY)] +#[Attribute(Attribute::TARGET_PROPERTY | Attribute::TARGET_PARAMETER)] class NotIn extends ObjectValidationAttribute { protected BaseNotIn $rule; @@ -22,7 +22,7 @@ public function __construct(array|string|BaseNotIn|RouteParameterReference ...$v } $values = array_map( - fn (string|RouteParameterReference $value) => $this->normalizePossibleRouteReferenceParameter($value), + fn(string|RouteParameterReference $value) => $this->normalizePossibleRouteReferenceParameter($value), Arr::flatten($values) ); diff --git a/src/Attributes/Validation/NotRegex.php b/src/Attributes/Validation/NotRegex.php index c7d62445..75455c86 100644 --- a/src/Attributes/Validation/NotRegex.php +++ b/src/Attributes/Validation/NotRegex.php @@ -5,7 +5,7 @@ use Attribute; use Spatie\LaravelData\Support\Validation\References\RouteParameterReference; -#[Attribute(Attribute::TARGET_PROPERTY)] +#[Attribute(Attribute::TARGET_PROPERTY | Attribute::TARGET_PARAMETER)] class NotRegex extends StringValidationAttribute { public function __construct(protected string|RouteParameterReference $pattern) diff --git a/src/Attributes/Validation/Nullable.php b/src/Attributes/Validation/Nullable.php index 8d8258f1..46e87dc6 100644 --- a/src/Attributes/Validation/Nullable.php +++ b/src/Attributes/Validation/Nullable.php @@ -4,7 +4,7 @@ use Attribute; -#[Attribute(Attribute::TARGET_PROPERTY)] +#[Attribute(Attribute::TARGET_PROPERTY | Attribute::TARGET_PARAMETER)] class Nullable extends StringValidationAttribute { public static function keyword(): string diff --git a/src/Attributes/Validation/Numeric.php b/src/Attributes/Validation/Numeric.php index 7bb18e59..2f3fd195 100644 --- a/src/Attributes/Validation/Numeric.php +++ b/src/Attributes/Validation/Numeric.php @@ -4,7 +4,7 @@ use Attribute; -#[Attribute(Attribute::TARGET_PROPERTY)] +#[Attribute(Attribute::TARGET_PROPERTY | Attribute::TARGET_PARAMETER)] class Numeric extends StringValidationAttribute { public static function keyword(): string diff --git a/src/Attributes/Validation/Password.php b/src/Attributes/Validation/Password.php index b72ed033..a6e0886b 100644 --- a/src/Attributes/Validation/Password.php +++ b/src/Attributes/Validation/Password.php @@ -8,22 +8,23 @@ use Spatie\LaravelData\Support\Validation\References\RouteParameterReference; use Spatie\LaravelData\Support\Validation\ValidationPath; -#[Attribute(Attribute::TARGET_PROPERTY)] +#[Attribute(Attribute::TARGET_PROPERTY | Attribute::TARGET_PARAMETER)] class Password extends ObjectValidationAttribute { protected BasePassword $rule; public function __construct( - int|RouteParameterReference $min = 12, + int|RouteParameterReference $min = 12, bool|RouteParameterReference $letters = false, bool|RouteParameterReference $mixedCase = false, bool|RouteParameterReference $numbers = false, bool|RouteParameterReference $symbols = false, bool|RouteParameterReference $uncompromised = false, - int|RouteParameterReference $uncompromisedThreshold = 0, + int|RouteParameterReference $uncompromisedThreshold = 0, bool|RouteParameterReference $default = false, - ?BasePassword $rule = null, - ) { + ?BasePassword $rule = null, + ) + { $min = $this->normalizePossibleRouteReferenceParameter($min); $letters = $this->normalizePossibleRouteReferenceParameter($letters); $mixedCase = $this->normalizePossibleRouteReferenceParameter($mixedCase); diff --git a/src/Attributes/Validation/Present.php b/src/Attributes/Validation/Present.php index 0b273eaf..a73ea81a 100644 --- a/src/Attributes/Validation/Present.php +++ b/src/Attributes/Validation/Present.php @@ -4,7 +4,7 @@ use Attribute; -#[Attribute(Attribute::TARGET_PROPERTY)] +#[Attribute(Attribute::TARGET_PROPERTY | Attribute::TARGET_PARAMETER)] class Present extends StringValidationAttribute { public static function keyword(): string diff --git a/src/Attributes/Validation/Prohibited.php b/src/Attributes/Validation/Prohibited.php index 62392630..b3df2f84 100644 --- a/src/Attributes/Validation/Prohibited.php +++ b/src/Attributes/Validation/Prohibited.php @@ -6,7 +6,7 @@ use Illuminate\Validation\Rules\ProhibitedIf; use Spatie\LaravelData\Support\Validation\ValidationPath; -#[Attribute(Attribute::TARGET_PROPERTY)] +#[Attribute(Attribute::TARGET_PROPERTY | Attribute::TARGET_PARAMETER)] class Prohibited extends ObjectValidationAttribute { public function __construct(protected ?ProhibitedIf $rule = null) diff --git a/src/Attributes/Validation/ProhibitedIf.php b/src/Attributes/Validation/ProhibitedIf.php index fd65d6a8..9aedf10f 100644 --- a/src/Attributes/Validation/ProhibitedIf.php +++ b/src/Attributes/Validation/ProhibitedIf.php @@ -8,7 +8,7 @@ use Spatie\LaravelData\Support\Validation\References\FieldReference; use Spatie\LaravelData\Support\Validation\References\RouteParameterReference; -#[Attribute(Attribute::TARGET_PROPERTY)] +#[Attribute(Attribute::TARGET_PROPERTY | Attribute::TARGET_PARAMETER)] class ProhibitedIf extends StringValidationAttribute { protected FieldReference $field; diff --git a/src/Attributes/Validation/ProhibitedUnless.php b/src/Attributes/Validation/ProhibitedUnless.php index 7a2e7ca2..4ed8f5a0 100644 --- a/src/Attributes/Validation/ProhibitedUnless.php +++ b/src/Attributes/Validation/ProhibitedUnless.php @@ -8,7 +8,7 @@ use Spatie\LaravelData\Support\Validation\References\FieldReference; use Spatie\LaravelData\Support\Validation\References\RouteParameterReference; -#[Attribute(Attribute::TARGET_PROPERTY)] +#[Attribute(Attribute::TARGET_PROPERTY | Attribute::TARGET_PARAMETER)] class ProhibitedUnless extends StringValidationAttribute { protected FieldReference $field; @@ -16,9 +16,10 @@ class ProhibitedUnless extends StringValidationAttribute protected string|array $values; public function __construct( - string|FieldReference $field, - array | string | BackedEnum | RouteParameterReference ...$values - ) { + string|FieldReference $field, + array|string|BackedEnum|RouteParameterReference ...$values + ) + { $this->field = $this->parseFieldReference($field); $this->values = Arr::flatten($values); } diff --git a/src/Attributes/Validation/Prohibits.php b/src/Attributes/Validation/Prohibits.php index 61104a3c..5f6397e5 100644 --- a/src/Attributes/Validation/Prohibits.php +++ b/src/Attributes/Validation/Prohibits.php @@ -6,7 +6,7 @@ use Illuminate\Support\Arr; use Spatie\LaravelData\Support\Validation\References\FieldReference; -#[Attribute(Attribute::TARGET_PROPERTY)] +#[Attribute(Attribute::TARGET_PROPERTY | Attribute::TARGET_PARAMETER)] class Prohibits extends StringValidationAttribute { protected array $fields; diff --git a/src/Attributes/Validation/Regex.php b/src/Attributes/Validation/Regex.php index 7ab578c2..0ea8c284 100644 --- a/src/Attributes/Validation/Regex.php +++ b/src/Attributes/Validation/Regex.php @@ -5,10 +5,10 @@ use Attribute; use Spatie\LaravelData\Support\Validation\References\RouteParameterReference; -#[Attribute(Attribute::TARGET_PROPERTY)] +#[Attribute(Attribute::TARGET_PROPERTY | Attribute::TARGET_PARAMETER)] class Regex extends StringValidationAttribute { - public function __construct(protected string | RouteParameterReference $pattern) + public function __construct(protected string|RouteParameterReference $pattern) { } diff --git a/src/Attributes/Validation/Required.php b/src/Attributes/Validation/Required.php index 4f341638..5cde323a 100644 --- a/src/Attributes/Validation/Required.php +++ b/src/Attributes/Validation/Required.php @@ -7,7 +7,7 @@ use Spatie\LaravelData\Support\Validation\RequiringRule; use Spatie\LaravelData\Support\Validation\ValidationPath; -#[Attribute(Attribute::TARGET_PROPERTY)] +#[Attribute(Attribute::TARGET_PROPERTY | Attribute::TARGET_PARAMETER)] class Required extends ObjectValidationAttribute implements RequiringRule { public function __construct(protected ?RequiredIf $rule = null) diff --git a/src/Attributes/Validation/RequiredIf.php b/src/Attributes/Validation/RequiredIf.php index 8ac45ee5..5ac3b4f8 100644 --- a/src/Attributes/Validation/RequiredIf.php +++ b/src/Attributes/Validation/RequiredIf.php @@ -9,7 +9,7 @@ use Spatie\LaravelData\Support\Validation\References\RouteParameterReference; use Spatie\LaravelData\Support\Validation\RequiringRule; -#[Attribute(Attribute::TARGET_PROPERTY)] +#[Attribute(Attribute::TARGET_PROPERTY | Attribute::TARGET_PARAMETER)] class RequiredIf extends StringValidationAttribute implements RequiringRule { protected FieldReference $field; @@ -17,9 +17,10 @@ class RequiredIf extends StringValidationAttribute implements RequiringRule protected string|array $values; public function __construct( - string|FieldReference $field, - array|string|BackedEnum | RouteParameterReference ...$values - ) { + string|FieldReference $field, + array|string|BackedEnum|RouteParameterReference ...$values + ) + { $this->field = $this->parseFieldReference($field); $this->values = Arr::flatten($values); } diff --git a/src/Attributes/Validation/RequiredUnless.php b/src/Attributes/Validation/RequiredUnless.php index a6c42b47..511d36ae 100644 --- a/src/Attributes/Validation/RequiredUnless.php +++ b/src/Attributes/Validation/RequiredUnless.php @@ -9,7 +9,7 @@ use Spatie\LaravelData\Support\Validation\References\RouteParameterReference; use Spatie\LaravelData\Support\Validation\RequiringRule; -#[Attribute(Attribute::TARGET_PROPERTY)] +#[Attribute(Attribute::TARGET_PROPERTY | Attribute::TARGET_PARAMETER)] class RequiredUnless extends StringValidationAttribute implements RequiringRule { protected FieldReference $field; @@ -17,9 +17,10 @@ class RequiredUnless extends StringValidationAttribute implements RequiringRule protected string|array $values; public function __construct( - string|FieldReference $field, - array|string|BackedEnum | RouteParameterReference ...$values - ) { + string|FieldReference $field, + array|string|BackedEnum|RouteParameterReference ...$values + ) + { $this->field = $this->parseFieldReference($field); $this->values = Arr::flatten($values); } diff --git a/src/Attributes/Validation/RequiredWith.php b/src/Attributes/Validation/RequiredWith.php index cbd3a711..6a77933c 100644 --- a/src/Attributes/Validation/RequiredWith.php +++ b/src/Attributes/Validation/RequiredWith.php @@ -7,7 +7,7 @@ use Spatie\LaravelData\Support\Validation\References\FieldReference; use Spatie\LaravelData\Support\Validation\RequiringRule; -#[Attribute(Attribute::TARGET_PROPERTY)] +#[Attribute(Attribute::TARGET_PROPERTY | Attribute::TARGET_PARAMETER)] class RequiredWith extends StringValidationAttribute implements RequiringRule { protected array $fields; diff --git a/src/Attributes/Validation/RequiredWithAll.php b/src/Attributes/Validation/RequiredWithAll.php index 5910af25..2f9add3d 100644 --- a/src/Attributes/Validation/RequiredWithAll.php +++ b/src/Attributes/Validation/RequiredWithAll.php @@ -7,7 +7,7 @@ use Spatie\LaravelData\Support\Validation\References\FieldReference; use Spatie\LaravelData\Support\Validation\RequiringRule; -#[Attribute(Attribute::TARGET_PROPERTY)] +#[Attribute(Attribute::TARGET_PROPERTY | Attribute::TARGET_PARAMETER)] class RequiredWithAll extends StringValidationAttribute implements RequiringRule { protected array $fields; diff --git a/src/Attributes/Validation/RequiredWithout.php b/src/Attributes/Validation/RequiredWithout.php index 7d2182fa..6f72eedc 100644 --- a/src/Attributes/Validation/RequiredWithout.php +++ b/src/Attributes/Validation/RequiredWithout.php @@ -7,7 +7,7 @@ use Spatie\LaravelData\Support\Validation\References\FieldReference; use Spatie\LaravelData\Support\Validation\RequiringRule; -#[Attribute(Attribute::TARGET_PROPERTY)] +#[Attribute(Attribute::TARGET_PROPERTY | Attribute::TARGET_PARAMETER)] class RequiredWithout extends StringValidationAttribute implements RequiringRule { protected array $fields; diff --git a/src/Attributes/Validation/RequiredWithoutAll.php b/src/Attributes/Validation/RequiredWithoutAll.php index ff1f2945..d13b728d 100644 --- a/src/Attributes/Validation/RequiredWithoutAll.php +++ b/src/Attributes/Validation/RequiredWithoutAll.php @@ -7,7 +7,7 @@ use Spatie\LaravelData\Support\Validation\References\FieldReference; use Spatie\LaravelData\Support\Validation\RequiringRule; -#[Attribute(Attribute::TARGET_PROPERTY)] +#[Attribute(Attribute::TARGET_PROPERTY | Attribute::TARGET_PARAMETER)] class RequiredWithoutAll extends StringValidationAttribute implements RequiringRule { protected array $fields; diff --git a/src/Attributes/Validation/Rule.php b/src/Attributes/Validation/Rule.php index 0aa3faae..2cd9025a 100644 --- a/src/Attributes/Validation/Rule.php +++ b/src/Attributes/Validation/Rule.php @@ -8,7 +8,7 @@ use Illuminate\Contracts\Validation\ValidationRule as ValidationRuleContract; use Spatie\LaravelData\Support\Validation\ValidationRule; -#[Attribute(Attribute::TARGET_PROPERTY)] +#[Attribute(Attribute::TARGET_PROPERTY | Attribute::TARGET_PARAMETER)] class Rule extends ValidationRule { /** @var array */ diff --git a/src/Attributes/Validation/Same.php b/src/Attributes/Validation/Same.php index 7b20362b..97fbe0b5 100644 --- a/src/Attributes/Validation/Same.php +++ b/src/Attributes/Validation/Same.php @@ -5,12 +5,12 @@ use Attribute; use Spatie\LaravelData\Support\Validation\References\FieldReference; -#[Attribute(Attribute::TARGET_PROPERTY)] +#[Attribute(Attribute::TARGET_PROPERTY | Attribute::TARGET_PARAMETER)] class Same extends StringValidationAttribute { protected FieldReference $field; - public function __construct(string | FieldReference $field) + public function __construct(string|FieldReference $field) { $this->field = $this->parseFieldReference($field); } diff --git a/src/Attributes/Validation/Size.php b/src/Attributes/Validation/Size.php index 7be1b9a7..72dd88c6 100644 --- a/src/Attributes/Validation/Size.php +++ b/src/Attributes/Validation/Size.php @@ -5,10 +5,10 @@ use Attribute; use Spatie\LaravelData\Support\Validation\References\RouteParameterReference; -#[Attribute(Attribute::TARGET_PROPERTY)] +#[Attribute(Attribute::TARGET_PROPERTY | Attribute::TARGET_PARAMETER)] class Size extends StringValidationAttribute { - public function __construct(protected int | RouteParameterReference $size) + public function __construct(protected int|RouteParameterReference $size) { } diff --git a/src/Attributes/Validation/Sometimes.php b/src/Attributes/Validation/Sometimes.php index 6c2d0310..51b4924b 100644 --- a/src/Attributes/Validation/Sometimes.php +++ b/src/Attributes/Validation/Sometimes.php @@ -4,7 +4,7 @@ use Attribute; -#[Attribute(Attribute::TARGET_PROPERTY)] +#[Attribute(Attribute::TARGET_PROPERTY | Attribute::TARGET_PARAMETER)] class Sometimes extends StringValidationAttribute { public static function keyword(): string diff --git a/src/Attributes/Validation/StartsWith.php b/src/Attributes/Validation/StartsWith.php index 59695659..a6b2069e 100644 --- a/src/Attributes/Validation/StartsWith.php +++ b/src/Attributes/Validation/StartsWith.php @@ -6,7 +6,7 @@ use Illuminate\Support\Arr; use Spatie\LaravelData\Support\Validation\References\RouteParameterReference; -#[Attribute(Attribute::TARGET_PROPERTY)] +#[Attribute(Attribute::TARGET_PROPERTY | Attribute::TARGET_PARAMETER)] class StartsWith extends StringValidationAttribute { protected string|array $values; diff --git a/src/Attributes/Validation/StringType.php b/src/Attributes/Validation/StringType.php index 814ba30b..55e995b7 100644 --- a/src/Attributes/Validation/StringType.php +++ b/src/Attributes/Validation/StringType.php @@ -4,7 +4,7 @@ use Attribute; -#[Attribute(Attribute::TARGET_PROPERTY)] +#[Attribute(Attribute::TARGET_PROPERTY | Attribute::TARGET_PARAMETER)] class StringType extends StringValidationAttribute { public static function keyword(): string diff --git a/src/Attributes/Validation/Timezone.php b/src/Attributes/Validation/Timezone.php index b8763afc..10cfddab 100644 --- a/src/Attributes/Validation/Timezone.php +++ b/src/Attributes/Validation/Timezone.php @@ -4,7 +4,7 @@ use Attribute; -#[Attribute(Attribute::TARGET_PROPERTY)] +#[Attribute(Attribute::TARGET_PROPERTY | Attribute::TARGET_PARAMETER)] class Timezone extends StringValidationAttribute { public static function keyword(): string diff --git a/src/Attributes/Validation/Unique.php b/src/Attributes/Validation/Unique.php index a00f59c5..47c6ff71 100644 --- a/src/Attributes/Validation/Unique.php +++ b/src/Attributes/Validation/Unique.php @@ -9,7 +9,7 @@ use Spatie\LaravelData\Support\Validation\References\RouteParameterReference; use Spatie\LaravelData\Support\Validation\ValidationPath; -#[Attribute(Attribute::TARGET_PROPERTY)] +#[Attribute(Attribute::TARGET_PROPERTY | Attribute::TARGET_PARAMETER)] class Unique extends ObjectValidationAttribute { protected BaseUnique $rule; @@ -20,11 +20,12 @@ public function __construct( null|string|RouteParameterReference $connection = null, null|string|RouteParameterReference $ignore = null, null|string|RouteParameterReference $ignoreColumn = null, - bool|RouteParameterReference $withoutTrashed = false, - string|RouteParameterReference $deletedAtColumn = 'deleted_at', - ?Closure $where = null, - ?BaseUnique $rule = null - ) { + bool|RouteParameterReference $withoutTrashed = false, + string|RouteParameterReference $deletedAtColumn = 'deleted_at', + ?Closure $where = null, + ?BaseUnique $rule = null + ) + { $table = $this->normalizePossibleRouteReferenceParameter($table); $column = $this->normalizePossibleRouteReferenceParameter($column); $connection = $this->normalizePossibleRouteReferenceParameter($connection); diff --git a/src/Attributes/Validation/Url.php b/src/Attributes/Validation/Url.php index e10a3598..743c8723 100644 --- a/src/Attributes/Validation/Url.php +++ b/src/Attributes/Validation/Url.php @@ -4,7 +4,7 @@ use Attribute; -#[Attribute(Attribute::TARGET_PROPERTY)] +#[Attribute(Attribute::TARGET_PROPERTY | Attribute::TARGET_PARAMETER)] class Url extends StringValidationAttribute { public static function keyword(): string diff --git a/src/Attributes/Validation/Uuid.php b/src/Attributes/Validation/Uuid.php index 1ce57b8e..d9b6eb6e 100644 --- a/src/Attributes/Validation/Uuid.php +++ b/src/Attributes/Validation/Uuid.php @@ -4,7 +4,7 @@ use Attribute; -#[Attribute(Attribute::TARGET_PROPERTY)] +#[Attribute(Attribute::TARGET_PROPERTY | Attribute::TARGET_PARAMETER)] class Uuid extends StringValidationAttribute { public static function keyword(): string diff --git a/src/Attributes/Validation/ValidationAttribute.php b/src/Attributes/Validation/ValidationAttribute.php index cbc3e110..6428347f 100644 --- a/src/Attributes/Validation/ValidationAttribute.php +++ b/src/Attributes/Validation/ValidationAttribute.php @@ -22,7 +22,7 @@ public function __toString(): string protected static function parseDateValue(mixed $value): mixed { - if (! is_string($value)) { + if (!is_string($value)) { return $value; } @@ -41,7 +41,7 @@ protected static function parseDateValue(mixed $value): mixed protected static function parseBooleanValue(mixed $value): mixed { - if (! is_string($value)) { + if (!is_string($value)) { return $value; } @@ -58,7 +58,8 @@ protected static function parseBooleanValue(mixed $value): mixed protected function parseFieldReference( string|FieldReference $reference - ): FieldReference { + ): FieldReference + { return $reference instanceof FieldReference ? $reference : new FieldReference($reference);