Make a failure instance with optional message.

@param CheckerInterface     $checker  The checker instance.
@param null|string|string[] $messages Optional. Result message.

@return Failure
437558
public static function makeFailure(CheckerInterface $checker, $messages = null): Failure
    {
        return new Failure(
            $checker,
            ...self::castIntoArray($messages)
        );
    }
588099
public function execute(InputInterface $input, OutputInterface $output)
    {
        if (!$input->getOption('stop-on-failure')) {
            return null;
        }

        if ($input->getOption('strict')) {
            $this->resultInterpretation = new StrictInterpretation();
        }

        $this->eventDispatcher->addListener(ScenarioTested::AFTER, array($this, 'exitOnFailure'), -100);
        $this->eventDispatcher->addListener(ExampleTested::AFTER, array($this, 'exitOnFailure'), -100);
    }
1092642
public function addValidator(Validator $validator) : ValidationCheckerInterface
    {
        $this->validated = false;
        $validator->setValidationSet($this);
        array_push($this->validators, $validator);
        return $this;
    }
145231
protected function executeChecker(
        ApplicableCheckerInterface $checker,
        ContextInterface $context,
        array $processorAttributes
    ) {
        return $checker->isApplicable($context, $processorAttributes);
    }
961839
public function createRuleFailedValidation(MessageBag $errors)
    {
        app('antares.messages')->add('error', $errors);
        $url = handles('ban_management.rules.create');

        return $this->redirectWithErrors($url, $errors);
    }
45081
public function rules($rules = null, $messages = [])
    {
        if ($rules instanceof \Closure) {
            $this->rules = $rules;
        }

        if (is_array($rules)) {
            $thisRuleArr = array_filter(explode('|', $this->rules));

            $this->rules = array_merge($thisRuleArr, $rules);
        } elseif (is_string($rules)) {
            $rules = array_filter(explode('|', "{$this->rules}|$rules"));

            $this->rules = implode('|', $rules);
        }

        $this->validationMessages = $messages;

        return $this;
    }
873644
public function originalChecksums(array $checksums = null) {
        if ($checksums === null) {
            return $this->originalChecksums;
        }

        $this->originalChecksums = $checksums;

        return $this;
    }
116698
public function errors($errors)
    {
        $this->success = false;
        $this->data['errors'] = $errors instanceof MessageBag
            ? $errors->toArray()
            : $errors;

        return $this;
    }
602563
public function getChecker(string $name): Autowire
    {
        if (!$this->hasChecker($name)) {
            throw new ValidationException("Undefined checker `{$name}``.");
        }

        $instance = $this->wire('checkers', $name);
        if (!empty($instance)) {
            return $instance;
        }

        throw new ValidationException("Invalid checker definition for `{$name}`.");
    }
330144
public function createValidator($validatorIdentifier, array $options = [])
    {
        $validatorPresets = $this->getRootForm()->getValidatorPresets();
        if (isset($validatorPresets[$validatorIdentifier]) && is_array($validatorPresets[$validatorIdentifier]) && isset($validatorPresets[$validatorIdentifier]['implementationClassName'])) {
            $implementationClassName = $validatorPresets[$validatorIdentifier]['implementationClassName'];
            $defaultOptions = isset($validatorPresets[$validatorIdentifier]['options']) ? $validatorPresets[$validatorIdentifier]['options'] : [];

            $options = Arrays::arrayMergeRecursiveOverrule($defaultOptions, $options);

            $validator = new $implementationClassName($options);
            $this->addValidator($validator);
            return $validator;
        } else {
            throw new ValidatorPresetNotFoundException('The validator preset identified by "' . $validatorIdentifier . '" could not be found, or the implementationClassName was not specified.', 1328710202);
        }
    }
1308223
protected function getFormattedErrors(ConstraintViolationListInterface $constraintViolations,
                                          callable $formatter = null)
    {
        $errors = [];

        if (is_null($formatter)) {
            $formatter = function(ConstraintViolationInterface $constraintViolation) {
                return new Entity\Error($constraintViolation->getPropertyPath(), $constraintViolation->getMessage());
            };
        }

        /** @var ConstraintViolationInterface $constraintViolation */
        foreach ($constraintViolations as $constraintViolation) {
            $errors[] = $formatter($constraintViolation);
        }

        return $errors;
    }
209280
public function setValidators(array $validators)
    {
        foreach ($validators as $validator) {
            if (is_string($validator) && is_subclass_of($validator, ValidatorInterface::class)) {
                $validator = new $validator();
            }

            $this->addValidator($validator);
        }

        return $this;
    }
798001
public function createRuleFailedValidation(MessageBag $errors)
    {
        $message = implode("\n\r", $errors->all());
        $this->error($message);
    }
487724
public static function fail($code = '', $message = '', $errors = [], $extras = [])
    {
        return self::loadResult(self::FAIL, $code, $message, $errors, $extras);
    }
1055008
public function on(\Closure $checker, \Closure $handler)
    {
        $this->managers[] = new Manager($checker, $handler);

        return $this;
    }
640336
private function createInvalidInputResponse(ConstraintViolationListInterface $errors): JsonResponse
    {
        $errorMessages = [];
        foreach ($errors as $error) {
            $errorMessages[] = $error->getMessage();
        }

        return $this->createGenericErrorResponse(implode(', ', $errorMessages));
    }
821166
public function send(MessageInterface $message, &$failures = null)
    {
        return $this->transport->send($message, $failures);
    }