diff --git a/docs/advanced-usage/validation-attributes.md b/docs/advanced-usage/validation-attributes.md index aabdc183..cb3ef7b2 100644 --- a/docs/advanced-usage/validation-attributes.md +++ b/docs/advanced-usage/validation-attributes.md @@ -589,6 +589,15 @@ public int $closure; public int $closure; ``` +### Lowercase + +[Docs](https://laravel.com/docs/9.x/validation#rule-lowercase) + +```php +#[Lowercase] +public string $closure; +``` + ### MacAddress [Docs](https://laravel.com/docs/9.x/validation#rule-mac) @@ -989,6 +998,15 @@ public string $closure; public string $closure; ``` +### Uppercase + +[Docs](https://laravel.com/docs/9.x/validation#rule-uppercase) + +```php +#[Uppercase] +public string $closure; +``` + ### Url [Docs](https://laravel.com/docs/9.x/validation#rule-url) diff --git a/src/Attributes/Validation/Lowercase.php b/src/Attributes/Validation/Lowercase.php new file mode 100644 index 00000000..71ead99f --- /dev/null +++ b/src/Attributes/Validation/Lowercase.php @@ -0,0 +1,19 @@ + Json::class, LessThan::keyword() => LessThan::class, LessThanOrEqualTo::keyword() => LessThanOrEqualTo::class, + Lowercase::keyword() => Lowercase::class, MacAddress::keyword() => MacAddress::class, Max::keyword() => Max::class, MaxDigits::keyword() => MaxDigits::class, @@ -196,6 +199,7 @@ protected function mapping(): array StringType::keyword() => StringType::class, Timezone::keyword() => Timezone::class, Unique::keyword() => Unique::class, + Uppercase::keyword() => Uppercase::class, Url::keyword() => Url::class, Ulid::keyword() => Ulid::class, Uuid::keyword() => Uuid::class, diff --git a/tests/Datasets/Attributes/RulesDataset.php b/tests/Datasets/Attributes/RulesDataset.php index 3e70ce68..0e7211cb 100644 --- a/tests/Datasets/Attributes/RulesDataset.php +++ b/tests/Datasets/Attributes/RulesDataset.php @@ -57,6 +57,7 @@ use Spatie\LaravelData\Attributes\Validation\Json; use Spatie\LaravelData\Attributes\Validation\LessThan; use Spatie\LaravelData\Attributes\Validation\LessThanOrEqualTo; +use Spatie\LaravelData\Attributes\Validation\Lowercase; use Spatie\LaravelData\Attributes\Validation\MacAddress; use Spatie\LaravelData\Attributes\Validation\Max; use Spatie\LaravelData\Attributes\Validation\MaxDigits; @@ -92,6 +93,7 @@ use Spatie\LaravelData\Attributes\Validation\Timezone; use Spatie\LaravelData\Attributes\Validation\Ulid; use Spatie\LaravelData\Attributes\Validation\Unique; +use Spatie\LaravelData\Attributes\Validation\Uppercase; use Spatie\LaravelData\Attributes\Validation\Url; use Spatie\LaravelData\Attributes\Validation\Uuid; use Spatie\LaravelData\Exceptions\CannotBuildValidationRule; @@ -312,6 +314,11 @@ function fixature( expected: 'lte:field', ); + yield fixature( + attribute: new Lowercase(), + expected: 'lowercase', + ); + yield fixature( attribute: new MacAddress(), expected: 'mac_address', @@ -397,6 +404,11 @@ function fixature( expected: 'timezone', ); + yield fixature( + attribute: new Uppercase(), + expected: 'uppercase', + ); + yield fixature( attribute: new Url(), expected: 'url',