Run validation events and return the finalize rules and phrases.

@param  array|string  $events
@param  array  $phrases

@return array
325369
protected function runValidationEvents($events, array $phrases)
    {
        is_array($events) || $events = (array) $events;

        $events = array_merge($this->getValidationEvents(), $events);

        $rules   = new Fluent($this->getBindedRules());
        $phrases = new Fluent(array_merge($this->getValidationPhrases(), $phrases));

        foreach ((array) $events as $event) {
            $this->validationDispatcher->fire($event, [& $rules, & $phrases]);
        }

        return [
            $rules->getAttributes(),
            $phrases->getAttributes(),
        ];
    }
226440
public function validate(array $inputs, array $rules)
    {
        $this->inputs = $inputs;

        foreach ($rules as $key => $rule) {
            /**
             * Formatting and validation of each rule
             * eg. name => "required|max:100|alpha"
             */
            foreach (explode("|", $rule) as $masque) {
                // In the box there is a | superflux.
                if (is_int($masque) || Str::len($masque) == "") {
                    continue;
                }

                // Error lists.
                $this->errors[$key] = [];

                // Mask on the required rule
                foreach ($this->compiles as $compile) {
                    $this->{'compile'.$compile}($key, $masque);
                }

                // We clean the list of errors if the key is valid
                if (empty($this->errors[$key])) {
                    unset($this->errors[$key]);
                }
            }
        }

        return new Validate(
            $this->fails,
            $this->last_message,
            $this->errors
        );
    }
1318454
public function createSuccess(array $events = []): EventCollection
    {
        Assert::assertThat(true, Assert::isTrue());

        return new EventSequence($events, $this->callVerifierFactory);
    }
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;
    }
801335
public function runValidate(array $rules = null)
    {
        // skip validation on empty rules
        if ($rules === null) {
            return true;
        }

        $success = true;
        // list each rule as single one
        foreach ($rules as $rule) {
            // 0 = field (property) name, 1 = filter name, 2 = filter value
            if ($rule[0] === null || $rule[1] === null) {
                continue;
            }

            $propertyName = $rule[0];
            $validationRule = $rule[1];
            $validationValue = null;
            if (isset($rule[2])) {
                $validationValue = $rule[2];
            }

            // check if target field defined as array and make recursive validation
            if (Any::isArray($propertyName)) {
                $cumulateValidation = true;
                foreach ($propertyName as $attrNme) {
                    // end false condition
                    if (!$this->validateRecursive($attrNme, $validationRule, $validationValue)) {
                        $cumulateValidation = false;
                    }
                }
                // assign total
                $validate = $cumulateValidation;
            } else {
                $validate = $this->validateRecursive($propertyName, $validationRule, $validationValue);
            }

            // do not change condition on "true" check's (end-false-condition)
            if ($validate === false) {
                $success = false;
            }
        }

        return $success;
    }
954637
public function validate($rules = [], $errors = [])
    {
        foreach ($rules as $param => $subRules) {
            $paramValue = $this->getParam($param);
            foreach ($subRules as $key => $rule) {
                $isError = false;
                if (!is_array($rule)) {
                    switch ($rule) {
                        case self::VALIDATE_REQUIRED:
                            if (is_null($paramValue)) {
                                $isError = true;
                            }
                            break;
                        case self::VALIDATE_MOBILE:
                            if (!ValidationHelper::isMobile($paramValue)) {
                                $isError = true;
                            }
                            break;
                    }
                } else {
                    switch ($key) {
                    case self::VALIDATE_ENUM:
                        if (!in_array($paramValue, $rule)) {
                            $isError = true;
                        }
                        break;
                    }
                }
                if ($isError) {
                    $errCode = self::ERROR_INVALID_PARAM;
                    $errMsg = self::errorMsg[self::ERROR_INVALID_PARAM];
                    if (is_array($rule)) {
                        $rule = $key;
                    }
                    if (isset($errors[$param][$rule]['code'])) {
                        $errCode = $errors[$param][$rule]['code'];
                    }
                    if (isset($errors[$param][$rule]['msg'])) {
                        $errMsg = str_replace('{param}', $param, $errors[$param][$rule]['msg']);
                    }
                    throw new ParamException($errMsg, $errCode);
                }
            }
        }
    }
699183
public function validate(array $data = [], array $rules = [], array $messages = [])
    {
        $this->prepareRecord($data, $rules, $messages);

        return $this->validateRecord();
    }
144876
public function validationRules(array $rules = array())
    {
        if (empty($rules)) {
            return $this->validationRules;
        }

        $this->validationRules = $rules;

        return $this;
    }
1102426
public function createEvents(array $events) {
        $results = [];
        foreach ($events as $index => $opts) {
            $route = isset($opts['event']['eventname']) ? $opts['event']['eventname'] : '';
            if (isset(static::$routes[$route])) {
                    $route_events = is_array(static::$routes[$route]) ? static::$routes[$route] : [static::$routes[$route]];
                    foreach ($route_events as $route_event) {
                    try {
                        $event = '\MXTranslator\Events\\'.$route_event;
                        foreach ((new $event())->read($opts) as $index => $result) {
                             array_push($results, $result);
                         }
                    } catch (UnnecessaryEvent $ex) {}
                }
            }
        }
        return $results;
    }
560354
public void setPhrases(java.util.Collection<String> phrases) {
        if (phrases == null) {
            this.phrases = null;
            return;
        }

        this.phrases = new java.util.ArrayList<String>(phrases);
    }
1057379
protected function filterEvents(array $events)
    {
        if (! $eventName = $this->option('event')) {
            return $events;
        }

        return collect($events)->filter(function ($listeners, $event) use ($eventName) {
            return Str::contains($event, $eventName);
        })->toArray();
    }
112488
public static function delete_calendar_events($events) {
        global $DB;

        // Parameter validation.
        $params = self::validate_parameters(self:: delete_calendar_events_parameters(), array('events' => $events));

        $transaction = $DB->start_delegated_transaction();

        foreach ($params['events'] as $event) {
            $eventobj = calendar_event::load($event['eventid']);

            // Let's check if the user is allowed to delete an event.
            if (!calendar_delete_event_allowed($eventobj)) {
                throw new moodle_exception('nopermissions', 'error', '', get_string('deleteevent', 'calendar'));
            }
            // Time to do the magic.
            $eventobj->delete($event['repeat']);
        }

        // Everything done smoothly, let's commit.
        $transaction->allow_commit();

        return null;
    }
89339
private function buildEventAggregateAsArray(array $events)
    {
        $returnArray = [];

        /** @var Event $event */
        foreach ($events as $event) {
            $returnArray[] = [
                'uuid' => (string) $event->uuid(),
                'version' => $event->version(),
                'payload' => $event->payload(),
                'type' => $event->type(),
                'body' => $event->body(),
                'occurred_on' => $event->occurredOn()->format('Y-m-d H:i:s.u')
            ];
        }

        return $returnArray;
    }
1070824
protected function _validatePhrase($phrase)
    {
        // Splits on one or more Tab or space.
        $parts = preg_split('/[ \\x09]+/', $phrase, -1, PREG_SPLIT_NO_EMPTY);

        $phrase_parts = array();
        while (count($parts) > 0){
            $phrase_parts[] = $this->_splitCheck($parts, ' ');
            for ($i = 0; $i < $this->index + 1; $i++)
                array_shift($parts);
        }

        foreach ($phrase_parts as $part) {
            // If quoted string:
            if (substr($part, 0, 1) == '"') {
                if (!$this->_validateQuotedString($part)) {
                    return false;
                }
                continue;
            }

            // Otherwise it's an atom:
            if (!$this->_validateAtom($part)) return false;
        }

        return true;
    }
213754
protected static function _validateTagsArray($tags)
    {
        if (!is_array($tags)) {
            Zend_Cache::throwException('Invalid tags array : must be an array');
        }
        foreach($tags as $tag) {
            self::_validateIdOrTag($tag);
        }
        reset($tags);
    }
689198
public function addEvents(array $events = array())
    {
        $events['projectId'] = $this->getConfig('projectId');
        $events['writeKey'] = $this->getKeyForWriting();

        $command = parent::getCommand('addEvents', $events);

        return $this->execute($command);
    }
1112207
public function runLast($commands)
    {
        $results = $this->runRaw($commands, true);
        $results = end($results);

        return $results;
    }