for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/**
* This file is part of Dimtrovich/Validation.
*
* (c) 2023 Dimitri Sitchet Tomkeu <[email protected]>
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace Dimtrovich\Validation\Rules;
use Rakit\Validation\Rule as RakitRule;
class MissingUnless extends Missing
{
* {@inheritDoc}
public function fillParameters(array $params): RakitRule
$this->params['field'] = array_shift($params);
$this->params['values'] = $params;
return $this;
}
public function check($value): bool
$this->requireParameters(['field', 'values']);
$anotherAttribute = $this->parameter('field');
$definedValues = $this->parameter('values');
$anotherValue = $this->getAttribute()->getValue($anotherAttribute);
if (! in_array($anotherValue, $definedValues, is_bool($anotherValue) || null === $anotherValue)) {
return parent::check($value);
return true;