Example of Custom validation rules in bytefury/crater

File app/Rules/Backup/PathToZip.php (link to Github)
use Illuminate\Contracts\Validation\Rule;
use Illuminate\Support\Str;

class PathToZip implements Rule
{
    public function passes($attribute, $value)
    {
        return Str::endsWith($value, '.zip');
    }

    public function message()
    {
        return 'The given value must be a path to a zip file.';
    }
}
File app/Http/Controllers/V1/Backup/DownloadBackupController.php (link to Github)
use Illuminate\Http\Request;
use Crater\Rules\Backup\PathToZip;

class DownloadBackupController extends ApiController
{
    public function __invoke(Request $request)
    {
        $validated = $request->validate([
            'path' => ['required', new PathToZip()],
        ]);
        //
    }
}

Additional resources on custom validation rules: