mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-09-29 18:20:01 +00:00
33 lines
887 B
PHP
33 lines
887 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace FireflyIII\Rules\Admin;
|
|
|
|
use FireflyIII\Support\Validation\ValidatesAmountsTrait;
|
|
use Illuminate\Contracts\Validation\ValidationRule;
|
|
use Illuminate\Support\Facades\Log;
|
|
|
|
class IsValidSlackUrl implements ValidationRule
|
|
{
|
|
use ValidatesAmountsTrait;
|
|
|
|
/**
|
|
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
|
|
*/
|
|
public function validate(string $attribute, mixed $value, \Closure $fail): void
|
|
{
|
|
$value = (string)$value;
|
|
if ('' === $value) {
|
|
return;
|
|
}
|
|
|
|
if (!str_starts_with($value, 'https://hooks.slack.com/services/')) {
|
|
$fail('validation.active_url')->translate();
|
|
$message = sprintf('IsValidSlackUrl: "%s" is not a slack URL.', substr($value, 0, 255));
|
|
Log::debug($message);
|
|
Log::channel('audit')->info($message);
|
|
}
|
|
}
|
|
}
|