mirror of
https://github.com/10h30/Test-Laravel-Validation.git
synced 2026-06-05 15:07:56 +09:00
24 lines
529 B
PHP
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');
|
|
}
|
|
}
|
|
}
|