diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index f0e9a50..6cb2e4e 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -7,7 +7,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - php-version: ['8.2', '8.3', '8.4'] + php-version: ['8.2', '8.3', '8.4', '8.5'] steps: - uses: actions/checkout@v3 diff --git a/src/DI/CaptchaExtension.php b/src/DI/CaptchaExtension.php index 86fdf5d..88e4259 100644 --- a/src/DI/CaptchaExtension.php +++ b/src/DI/CaptchaExtension.php @@ -12,6 +12,7 @@ use Nette\DI\CompilerExtension; use Nette\Forms\Container; use Nette\PhpGenerator\ClassType; +use Nette\Schema\Context; use Nette\Schema\Expect; use Nette\Schema\Schema; @@ -23,12 +24,12 @@ class CaptchaExtension extends CompilerExtension public function getConfigSchema(): Schema { return Expect::structure([ - 'type' => Expect::anyOf(CaptchaType::TURNSTILE->value, CaptchaType::HCAPTCHA->value)->default(CaptchaType::TURNSTILE)->transform(fn (string $value) => CaptchaType::from($value)), + 'type' => Expect::anyOf(CaptchaType::TURNSTILE->value, CaptchaType::HCAPTCHA->value)->default(CaptchaType::TURNSTILE)->transform(fn (mixed $value, Context $context): CaptchaType => $value instanceof CaptchaType ? $value : (is_string($value) ? CaptchaType::from($value) : CaptchaType::TURNSTILE)), 'secretKey' => Expect::string()->required(), 'siteKey' => Expect::string()->required(), 'verifyUrl' => Expect::string()->nullable(), - 'theme' => Expect::anyOf(Theme::LIGHT->value, Theme::DARK->value, Theme::AUTO->value)->default(Theme::AUTO)->transform(fn (string $value) => Theme::from($value)), - 'size' => Expect::anyOf(Size::NORMAL->value, Size::COMPACT->value)->default(Size::NORMAL)->transform(fn (string $value) => Size::from($value)), + 'theme' => Expect::anyOf(Theme::LIGHT->value, Theme::DARK->value, Theme::AUTO->value)->default(Theme::AUTO)->transform(fn (mixed $value, Context $context): Theme => $value instanceof Theme ? $value : (is_string($value) ? Theme::from($value) : Theme::AUTO)), + 'size' => Expect::anyOf(Size::NORMAL->value, Size::COMPACT->value)->default(Size::NORMAL)->transform(fn (mixed $value, Context $context): Size => $value instanceof Size ? $value : (is_string($value) ? Size::from($value) : Size::NORMAL)), ]); }