Files
Test-Laravel-Validation/app/Rules/Uppercase.php
T
2025-04-21 13:06:16 +09:00

24 lines
529 B
PHP

<?php
namespace App\Rules;
use Closure;
use Illuminate\Contracts\Validation\ValidationRule;
class Uppercase implements ValidationRule
{
/**
* Run the validation rule.
*
* @param \Closure(string): \Illuminate\Translation\PotentiallyTranslatedString $fail
*/
public function validate(string $attribute, mixed $value, Closure $fail): void
{
//
if ((ucfirst($value)) !== $value)
{
$fail('The title does not start with an uppercased letter');
}
}
}