Provides 'empty_with' validation rule for Laravel

@return bool
774198
public function validateEmptyWith($attribute, $value, $parameters)
    {
        $values = [];

        foreach ($parameters as $parameter) {
            $values[] = $this->getValue($parameter);
        }

        return Validator::isEmptyWith($value, $values);
    }
719901
public function isValid()
    {
        // get files for upload
        $this->files = $this->request->getUploadedFiles();

        if (sizeof($this->files) > 0) {

            // do any actions if files exists

            foreach ($this->files as $n => $file) {

                // apply all the validation rules for each file

                foreach ($this->rules as $key => $rule) {

                    if (method_exists($this->validator, 'check' . ucfirst($key)) === true) {
                        $this->validator->{'check' . ucfirst($key)}($file, $rule);
                    }
                }
            }
        }

        $errors = $this->getErrors();

        return (empty($errors) === true) ? true : false;
    }
315442
public function getModelStaticValidationRules()
    {
        $model = $this->getDataModel();

        return isset($model::$rules) && is_array($model::$rules) ? $model::$rules : false;
    }
757086
public function validate() {
        // Deny if rules array is empty
        if (empty($this->rules))
            return true;
        // If rules are invalid
        if (!is_array($this->rules))
            throw new \Exception("The rules must be an array of the validator|sanitize rules", 1);
        // Loop the rules
        foreach ($this->rules as $rule) {
            // Run rule
            $rule instanceof \Closure
                ? $rule($this)
                : call_user_func($rule, $this);
        }
        // Check the field is valid
        return !$this->hasError();
    }
1188727
private function validateRecord()
    {
        // Abort if beforeValidate() fails
        if ($this->fireModelEvent('validating') === false) return false;

        $validator = Validator::make($this->getAttributes(), $this->rules, $this->messages);
        $result = $validator->passes();

        // Update errors based on result
        $this->errors = ($result) ? new MessageBag : $validator->messages();

        $this->fireModelEvent('validated', false);

        return $result;
    }
654834
public function validateValidItem()
    {
        if (!$this->value) {
            return;
        }

        // load allowed values in values_list
        // @todo Imants: Actually we don't need to load all values from Model in
        //       array, just to check couple of posted values.
        //       Probably we should do SELECT * FROM t WHERE id IN ($values) or
        //       something like that to limit array size and time spent on
        //       parsing all DB records in Model.
        $this->getValueList();

        $values = explode($this->separator, $this->value);
        foreach ($values as $v) {
            if (!isset($this->value_list[$v])) {
                $this->displayFieldError("Value $v is not one of the offered values");

                return $this->validate();
            }
        }
    }
517594
public function isNull()
    {
        $values = $this->getValue();
        if (is_array($values)) {
            return empty($values) || count($values) <= 0;
        } elseif (is_string($values)) {
            return !isset($values) || trim($values) === '';
        } else {
            return is_null($values);
        }
    }
174796
public function isValid()
    {
        if (!$rules = $this->rules()) {
            return true;
        }

        $attributes = $this->getAttributes();

        // Verify attributes that are hashed and that have not changed
        // those doesn't need to be validated.
        foreach ($this->hashedAttributes as $hashedAttr) {
            if (isset($this->original[$hashedAttr]) && $this->$hashedAttr == $this->original[$hashedAttr]) {
                unset($rules[$hashedAttr]);
            }
        }

        // Creates validator with attributes and the rules of the object
        $validator = app(ValidationFactory::class)->make($attributes, $rules, $this->messages());

        // Validate and attach errors
        if ($hasErrors = $validator->fails()) {
            $this->errors = $validator->errors();
        }

        return !$hasErrors;
    }
933878
public function validate() {
        if (!$this->_data) {
            return false;
        }

        $fields = $this->getFields();
        $messages = $this->getMessages();

        foreach ($this->_data as $field => $value) {
            if (empty($this->_rules[$field])) {
                continue;
            }

            foreach ($this->_rules[$field] as $rule => $params) {
                $options = $params['options'];
                $arguments = $options;
                array_unshift($arguments, $value);

                // Use G11n if it is available
                if (class_exists('Titon\G11n\Utility\Validate')) {
                    $class = 'Titon\G11n\Utility\Validate';
                } else {
                    $class = 'Titon\Utility\Validate';
                }

                if (!call_user_func(array($class, 'hasMethod'), $rule)) {
                    throw new InvalidValidationRuleException(sprintf('Validation rule %s does not exist', $rule));
                }

                // Prepare messages
                $message = $params['message'];

                if (!$message && isset($messages[$rule])) {
                    $message = $messages[$rule];
                }

                if ($message) {
                    $message = String::insert($message, array_map(function($value) {
                        return is_array($value) ? implode(', ', $value) : $value;
                    }, $options + array(
                        'field' => $field,
                        'title' => $fields[$field]
                    )));
                } else {
                    throw new InvalidValidationRuleException(sprintf('Error message for rule %s does not exist', $rule));
                }

                if (!call_user_func_array(array($class, $rule), $arguments)) {
                    $this->addError($field, $message);
                    break;
                }
            }
        }

        return empty($this->_errors);
    }
1078646
public function isEmpty()
    {
        $isEmpty = empty($this->storage);

        if ($isEmpty === false) {
            if ($this->length() == 1) {
                if (is_null($this->values()[0])) {
                    $isEmpty = true;
                }
            }
        }

        return $isEmpty;
    }
453633
public function validateTranslations()
    {
        $valid = !empty($this->_models);
        $activeTranslations = 0;
        foreach ($this->_models as $model) {
            if ($this->isTranslationActive($model)) {
                $activeTranslations++;
                $valid = $valid && $model->validate();
            }
        }
        return $activeTranslations>0 && $valid;
    }
854470
private function __validate()
    {
        $blnReturn = true;

        foreach ($this->__elements as $element) {
            if (! $element->isValid()) {
                $blnReturn = false;
                break;
            }
        }

        return $blnReturn;
    }
638376
protected function validateFilters()
  {
    if (!empty($this->value) && !empty($this->filters)) {
      foreach ($this->filters as $filter) {
        if (is_array($this->value) && $this->isMultipleChoiceAllowed()) {
          $this->value = Filter::Arr($this->value, $filter, null);

          $bad = empty($this->value);
        } else {
          $bad = is_null(Filter::Value($this->value, $filter, null));
        }

        if ($bad) {
          $this->addError(sprintf($this->tmpl_err_wrong, $this->getName()));

          return false;
        }
      }
    }

    return true;
  }
739505
public function blank()
    {
        $message = ['%s is {{not|}} empty', $this->value];
        $this->assert((empty($this->value)), $message);

        return $this;
    }
967633
public function validate()
    {
        $valid = true;
        $message = null;
        $type = $this->Type;

        // Check if empty strings
        switch ($type) {
            case 'URL':
            case 'Email':
            case 'Phone':
                if ($this->{$type} == '') {
                    $valid = false;
                    $message = _t(
                        __CLASS__ . '.VALIDATIONERROR_EMPTY'.strtoupper($type),
                        'You must enter a {TypeLabel}',
                        [
                            'TypeLabel' => $this->TypeLabel
                        ]
                    );
                }
                break;
            case 'File':
            case 'SiteTree':
                if ($type && empty($this->{$type.'ID'})) {
                    $valid = false;
                    $message = _t(
                        __CLASS__ . '.VALIDATIONERROR_OBJECT',
                        'Please select a {TypeLabel}',
                        [
                            'TypeLabel' => $this->TypeLabel
                        ]
                    );
                }
                break;
        }
        // if its already failed don't bother checking the rest
        if ($valid) {
            switch ($type) {
                case 'URL':
                    $allowedFirst = ['#', '/'];
                    if (!in_array(substr($this->URL, 0, 1), $allowedFirst) && !filter_var($this->URL, FILTER_VALIDATE_URL)) {
                        $valid = false;
                        $message = _t(
                            __CLASS__ . '.VALIDATIONERROR_VALIDURL',
                            'Please enter a valid URL.  Be sure to include http:// for an external URL. or begin your internal url/anchor with a "/" character'
                        );
                    }
                    break;
                case 'Email':
                    if (!filter_var($this->Email, FILTER_VALIDATE_EMAIL)) {
                        $valid = false;
                        $message = _t(
                            __CLASS__ . '.VALIDATIONERROR_VALIDEMAIL',
                            'Please enter a valid Email address'
                        );
                    }
                    break;
                case 'Phone':
                    if (!preg_match("/^\+?[0-9a-zA-Z\-\s]*[\,\#]?[0-9\-\s]*$/", $this->Phone)) {
                        $valid = false;
                        $message = _t(
                            __CLASS__ . '.VALIDATIONERROR_VALIDPHONE',
                            'Please enter a valid Phone number'
                        );
                    }
                    break;
            }
        }

        $result = ValidationResult::create();
        if (!$valid) {
            $result->addError($message);
        }

        $this->extend('updateValidate', $result);

        return $result;
    }
701601
public function isValid()
    {
        $value = $this->field->getValue();

        // field is empty and its not required. It's thus valid.
        if ($value == '' && $this->required == false) {
            return true;
        }

        $parsedDate = date_parse($value);

        if ($parsedDate['warning_count'] == 0 &&
            $parsedDate['error_count'] == 0 &&
            isset($parsedDate['year']) &&
            isset($parsedDate['month'])
        ) {
            return true;
        }

        return false;
    }
875028
public function isExempt()
    {
        /*
         * This would grab the exempted routes from the maintenance.php config file
         *
         * An example of this file:
         * return [
         *   'exemptions' => [
         *     'user-groups' => [ 1, 2, 3 ],
         *   ],
         * ];
         */

        $exemptGroups = $this->app['config']->get('maintenancemode.exemptions.user-groups', []);
        $currentUser = $this->app['auth']->user();
        if(is_array($exemptGroups) && $currentUser !== null)
        {
            // Grab the current user group IDs
            $currentUserGroups = $currentUser->groups->modelKeys();

            // Check to see if the user is within this group
            if((is_array($currentUserGroups) && count(array_intersect($currentUserGroups, $exemptGroups))) ||
                !is_array($currentUserGroups) && in_array($currentUserGroups, $exemptGroups))
            {
                // The user matched the whitelist, they will NOT see the maintenance page
                return true;
            }
        }

        // The current user did not match the whitelist, therefore they MIGHT see the maintenance page (depending on other exemptions)
        return false;
    }