mirror of
https://github.com/flarum/core.git
synced 2025-08-06 08:27:42 +02:00
fix: improve the flarum validator (#4133)
This commit is contained in:
@@ -1,31 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Flarum.
|
||||
*
|
||||
* For detailed copyright and license information, please view the
|
||||
* LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Flarum\ExtensionManager;
|
||||
|
||||
use Illuminate\Validation\Validator;
|
||||
|
||||
/**
|
||||
* @todo: fix in 2.0
|
||||
*/
|
||||
trait AllValidatorRules
|
||||
{
|
||||
protected function makeValidator(array $attributes): Validator
|
||||
{
|
||||
$rules = $this->getRules();
|
||||
|
||||
$validator = $this->validator->make($attributes, $rules, $this->getMessages());
|
||||
|
||||
foreach ($this->configuration as $callable) {
|
||||
$callable($this, $validator);
|
||||
}
|
||||
|
||||
return $validator;
|
||||
}
|
||||
}
|
@@ -13,7 +13,7 @@ use Flarum\Foundation\AbstractValidator;
|
||||
|
||||
class ConfigureAuthValidator extends AbstractValidator
|
||||
{
|
||||
use AllValidatorRules;
|
||||
protected bool $validateMissingKeys = true;
|
||||
|
||||
protected array $rules = [
|
||||
'github-oauth' => ['sometimes', 'array'],
|
||||
|
@@ -13,7 +13,7 @@ use Flarum\Foundation\AbstractValidator;
|
||||
|
||||
class ConfigureComposerValidator extends AbstractValidator
|
||||
{
|
||||
use AllValidatorRules;
|
||||
protected bool $validateMissingKeys = true;
|
||||
|
||||
protected array $rules = [
|
||||
'minimum-stability' => ['sometimes', 'in:stable,RC,beta,alpha,dev'],
|
||||
|
Reference in New Issue
Block a user