1. Go to this page and download the library: Download a-h-abid/laravalerors library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
namespace App\Rules;
use Closure;
use Illuminate\Contracts\Validation\ValidationRule;
class InCategory implements ValidationRule
{
/** @var string */
public const RULE_NAME = 'in-category';
/** @var array<int,string> */
public const RULE_PARAMS = ['a', 'b', 'c'];
/**
* Run the validation rule.
*
* @param \Closure(string): \Illuminate\Translation\PotentiallyTranslatedString $fail
*/
public function validate(string $attribute, mixed $value, Closure $fail): void
{
if (!in_array($value, static::RULE_PARAMS)) {
$fail('The :attribute you provided is not within the acceptable options.');
}
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.