Implements hook "validator.handlers"
@param array $handlers
176291
public function hookValidatorHandlers(array &$handlers)
    {
        foreach (array_keys($this->getHandlers()) as $command_id) {
            $class = str_replace('_', '', $command_id);
            $handlers["file_manager_$command_id"] = array(
                'handlers' => array(
                    'validate' => array("gplcart\\modules\\file_manager\\handlers\\validators\\$class", "validate$class")
                ),
            );
        }

        $handlers['file_manager_settings'] = array(
            'handlers' => array(
                'validate' => array('gplcart\\modules\\file_manager\\handlers\\validators\\Settings', 'validateSettings')
            ),
        );
    }
586225
private function validatePersisters(array $persisters)
    {
        foreach ($persisters as $name => $config) {
            $this->validateTypeAndService($config, sprintf('as3_modlr.persisters.%s', $name));
            switch ($config['type']) {
                case 'mongodb':
                    $this->validateLibClassExists('Persister\MongoDb\Persister', sprintf('as3_modlr.persisters.%s.type', $name));
                    $this->validatePersisterMongoDb($config);
                    break;
                default:
                    break;
            }
        }
    }
109583
public function messageinbound_handlers_table(array $handlers) {
        global $CFG;

        $table = new html_table();
        $handlername = new html_table_cell(get_string('name', 'tool_messageinbound') . "\n" .
                html_writer::tag('span', get_string('classname', 'tool_messageinbound'), array('class' => 'handler-function')));

        // Prepare some of the rows with additional styling.
        $enabled = new html_table_cell(get_string('enabled', 'tool_messageinbound'));
        $enabled->attributes['class'] = 'state';
        $edit = new html_table_cell(get_string('edit', 'tool_messageinbound'));
        $edit->attributes['class'] = 'edit';
        $table->head  = array(
                $handlername,
                get_string('description', 'tool_messageinbound'),
                $enabled,
                $edit,
            );
        $table->attributes['class'] = 'admintable generaltable messageinboundhandlers';

        $yes = get_string('yes');
        $no = get_string('no');

        $data = array();

        // Options for description formatting.
        $descriptionoptions = new stdClass();
        $descriptionoptions->trusted = false;
        $descriptionoptions->noclean = false;
        $descriptionoptions->smiley = false;
        $descriptionoptions->filter = false;
        $descriptionoptions->para = true;
        $descriptionoptions->newlines = false;
        $descriptionoptions->overflowdiv = true;

        $editurlbase = new moodle_url('/admin/tool/messageinbound/index.php');
        foreach ($handlers as $handler) {
            $handlername = new html_table_cell($handler->name . "\n" .
                    html_writer::tag('span', $handler->classname, array('class' => 'handler-function')));
            $handlername->header = true;

            $editurl = new moodle_url($editurlbase, array('classname' => $handler->classname));
            $editlink = $this->action_icon($editurl, new pix_icon('t/edit',
                    get_string('edithandler', 'tool_messageinbound', $handler->classname)));

            // Prepare some of the rows with additional styling.
            $enabled = new html_table_cell($handler->enabled ? $yes : $no);
            $enabled->attributes['class'] = 'state';
            $edit = new html_table_cell($editlink);
            $edit->attributes['class'] = 'edit';

            // Add the row.
            $row = new html_table_row(array(
                        $handlername,
                        format_text($handler->description, FORMAT_MARKDOWN, $descriptionoptions),
                        $enabled,
                        $edit,
                    ));

            if (!$handler->enabled) {
                $row->attributes['class'] = 'disabled';
            }
            $data[] = $row;
        }
        $table->data = $data;
        return html_writer::table($table);
    }
1060820
final public function bindToValidation(array $bindings): self
    {
        $this->validationBindings = \array_merge($this->validationBindings, $bindings);

        return $this;
    }
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;
    }
41644
public function setEvents(array $events)
	{
		if ($events) {
			$this->ensureEvents();
			
			foreach ($events as $name => $handler) {
				$this->on($name, $handler);
			}
		}
	}
688588
public function validate( $vars = null ) {
		$vars = $vars ?: $_POST;
		$this->values = [];
		$this->errors = [];
		$arrayInvalids = [];

		$cleaned = filter_var_array( $vars, $this->params );

		foreach ( $this->params as $name => $opt ) {
			$clean = isset( $vars[$name] ) ? $cleaned[$name] : null;

			if ( $clean === false &&
				$opt['filter'] !== \FILTER_VALIDATE_BOOLEAN
			) {
				$this->values[$name] = null;

			} elseif ( is_array( $clean ) &&
				( $opt['flags'] & \FILTER_REQUIRE_ARRAY ) &&
				$opt['filter'] !== \FILTER_VALIDATE_BOOLEAN
			) {
				// Strip invalid value markers from input array
				$this->values[$name] = [];
				foreach ( $clean as $key => $value ) {
					if ( $opt['filter'] !== \FILTER_VALIDATE_BOOLEAN &&
						$value !== false
					) {
						$this->values[$name][$key] = $value;

					} elseif ( $opt['filter'] === \FILTER_VALIDATE_BOOLEAN &&
						$value !== null
					) {
						$this->values[$name][$key] = $value;

					} else {
						// Keep track of invalid keys in case input was
						// required
						if ( !isset( $arrayInvalids[$name] ) ) {
							$arrayInvalids[$name] = [];
						}
						$arrayInvalids[$name][] = "{$name}[{$key}]";
					}
				}

			} else {
				$this->values[$name] = $clean;
			}

			if ( $opt['required'] && $this->values[$name] === null ) {
				$this->errors[] = $name;

			} elseif ( $opt['required'] && isset( $arrayInvalids[$name] ) ) {
				$this->errors = array_merge(
					$this->errors, $arrayInvalids[$name]
				);

			} elseif ( is_callable( $opt['validate'] ) &&
				call_user_func( $opt['validate'], $this->values[$name] ) === false
			) {
				$this->errors[] = $name;
				$this->values[$name] = null;
			}
		}

		$this->customValidationHook();

		return count( $this->errors ) === 0;
	}
993919
protected function validateHandlerOptions(
        $fromHandlers,
        $toHandlers,
        OutputInterface $output
    ) {
        foreach (['From' => $fromHandlers, 'To' => $toHandlers] as $direction => $handlers) {
            $lowerDirection = strtolower($direction);
            if (count($handlers) !== 2) {
                $output->writeln(
                    "Enter two comma separated values for the --$lowerDirection option: " .
                    "<{$lowerDirection}_metadata_handler>,<{$lowerDirection}_binarydata_handler>"
                );

                return false;
            }

            foreach (['meta' => $handlers[0], 'binary' => $handlers[1]] as $fileDataType => $handler) {
                if (!in_array($handler, array_keys(
                    $fileDataType === 'meta' ? $this->configuredMetadataHandlers : $this->configuredBinarydataHandlers
                ))) {
                    $output->writeln("$direction $fileDataType data handler '$handler' is not configured.");
                    $this->outputConfiguredHandlers($output);

                    return false;
                }
            }
        }

        if ($fromHandlers === $toHandlers) {
            $output->writeln('From and to handlers are the same. Nothing to do.');

            return false;
        }

        return true;
    }
539179
public function setHandlers($handlers)
    {
        $this->handlers = $handlers;
        $this->setKey($this->getKey());

        return $this;
    }
382363
public function validate(array $fields)
    {
        $this->flashInput($fields);

        $rules = $this->getValidationRules($fields);

        $validator = $this->getValidatorInstance($rules);

        if($validator->fails()){

            $this->failedValidation($validator);
        }
    }
655815
public function setValidations(ArrayObject $validations) {
        foreach ($validations as $param => $validation) {
            $this->setValidation($param, $validation);
        }
        return $this;
    }
1138315
protected function validate(array $data)
    {
        $validator = Validator::make($data, $this->rules);

        if ($validator->fails()) {
            throw new FormValidationException(trans('dashboard::dashboard.errors.form.validation'), $validator);
        }
    }
902742
public function dispatchBatch($channel, array $events)
    {
        $messages = [];
        $validates = true;

        foreach ($events as $event) {
            /** @var EventInterface $event */
            $event = $this->prepEventForDispatch($event);

            if ($this->validator) {
                $result = $this->validator->validate($event);
                if ($result->fails()) {
                    $validates = false;

                    // pass to validation fail handler?
                    if ($this->validationFailHandler) {
                        call_user_func($this->validationFailHandler, $result);
                    }

                    if ($this->throwValidationExceptionsOnDispatch) {
                        throw new ValidationException($result);
                    }
                }
            }

            $messages[] = $event->toMessage();
        }

        if ($validates) {
            $this->adapter->publishBatch($channel, $messages);
        }
    }
758078
@Override
	public void registerErrorHandlers(ErrorHandler... handlers) {
		if (handlers != null) {
			for (ErrorHandler handler : handlers) {
				this.registerErrorHandler(handler);
			}
		}
	}
657242
public function registerHandlers(array $handlers)
    {
        foreach ($handlers as $type => $handler) {
            if (!is_string($type)) {
                // Probably, non-string $type is a numeric index, which means,
                // that the handler array was defined as [ $handler1, $handler2, ... ] without handler types.
                // So try to guess the type.
                $type = $this->guessHandlerType($handler);
            }

            $this->registerHandler($handler, $type);
        }

        return $this;
    }
1224121
protected function registerSwooleEvents($handler, array $events)
    {
        foreach ($events as $event => $beanName) {
            $object = bean($beanName);
            $method = SwooleEvent::getHandlerFunction($event);
            $handler->on($event, [$object, $method]);
        }
    }
1307624
public function setExtensionHandlers(array $handlers)
    {
        $assoc = [];
        foreach ($handlers as $handler) {
            $assoc[$handler->getHandledKeyword()] = $handler;
        }
        uasort($assoc, function ($a, $b) {
            return $a->getPriorityOver($b->getHandledKeyword());
        });
        $this->handlers = $assoc;
        $this->setHandlerParams();

        return $this;
    }