From c4411687db8781d3f2fe00d41a796cd32ec46dde Mon Sep 17 00:00:00 2001 From: MohammadRezae Date: Sun, 25 May 2025 13:20:44 +0330 Subject: [PATCH 1/3] feat(validation.md): Add explanation and example for nullable validation rule --- validation.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/validation.md b/validation.md index ef18ae4388..7fbc56d42d 100644 --- a/validation.md +++ b/validation.md @@ -940,6 +940,15 @@ After defining this value, the validation rule will produce the following error ```text The credit card number field is required when payment type is credit card. ``` +### nullable + +The `nullable` rule allows a field to be `null`. If the field is `null`, no other validation rules will be applied to it. + +```php +$request->validate([ + 'middle_name' => ['nullable', 'string', 'max:50'], +]); +``` ## Available Validation Rules From 8d5a8c8d8f3cc9f29db06c914e9c901c0f296416 Mon Sep 17 00:00:00 2001 From: MohammadRezae Date: Sun, 25 May 2025 15:18:08 +0330 Subject: [PATCH 2/3] refactor(add explanation and example for prohibited_if rule): This PR adds a clear explanation and usage example for the `prohibited_if` validation rule in Laravel 12's validation documentation. This helps developers better understand how to dynamically exclude fields from requests based on the value of another field. --- validation.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/validation.md b/validation.md index 7fbc56d42d..11ff1849f5 100644 --- a/validation.md +++ b/validation.md @@ -949,7 +949,16 @@ $request->validate([ 'middle_name' => ['nullable', 'string', 'max:50'], ]); ``` +### prohibited_if +The `prohibited_if` rule prohibits a field from being present if another specified field has a certain value. This is useful for creating dynamic forms where some fields should be excluded based on the values of others. + +```php +$request->validate([ + 'company_name' => 'prohibited_if:is_freelancer,true', + 'is_freelancer' => 'boolean', +]); +``` ## Available Validation Rules From bd89e9991220f93122503dbda30a836606cfbbe7 Mon Sep 17 00:00:00 2001 From: MohammadRezae Date: Sun, 25 May 2025 15:30:11 +0330 Subject: [PATCH 3/3] Revert "refactor(add explanation and example for prohibited_if rule): This PR adds a clear explanation and usage example for the `prohibited_if` validation rule in Laravel 12's validation documentation. This helps developers better understand how to dynamically exclude fields from requests based on the value of another field." This reverts commit 8d5a8c8d8f3cc9f29db06c914e9c901c0f296416. --- validation.md | 9 --------- 1 file changed, 9 deletions(-) diff --git a/validation.md b/validation.md index 11ff1849f5..7fbc56d42d 100644 --- a/validation.md +++ b/validation.md @@ -949,16 +949,7 @@ $request->validate([ 'middle_name' => ['nullable', 'string', 'max:50'], ]); ``` -### prohibited_if -The `prohibited_if` rule prohibits a field from being present if another specified field has a certain value. This is useful for creating dynamic forms where some fields should be excluded based on the values of others. - -```php -$request->validate([ - 'company_name' => 'prohibited_if:is_freelancer,true', - 'is_freelancer' => 'boolean', -]); -``` ## Available Validation Rules