メンバの値にエラーがあるか調べる

@return boolean エラーがあるとき true、それ以外のとき false
427030
public function hasError()
    {
        if (empty($this->validation_errors)) {
            return false;
        }
        foreach ($this->validation_errors as $v) {
            foreach ($v as $w) {
                if ($w) {
                    return true;
                }
            }
        }
        return false;
    }
930978
public function getValidationErrors()
    {
        return [
            /** Bundle option related errors */
            __('The options you selected are not available.')->render(),
            __('The required options you selected are not available.')->render(),
            __('Please specify product option(s).')->render(),
            __('Please select all required options.')->render(),
            __('You need to choose options for your item.')->render(),

            /** Input field related errors */
            __('The text is too long.')->render(),
            __('Please specify product\'s required option(s).')
        ];
    }
234424
public function checkValid()
    {
        // error code/message already set
        if ($this->error_code && $this->error_message) {
            return false;
        }

        // missing jsonrpc or method
        if (!$this->json_rpc || !$this->method) {
            $this->error_code = self::ERROR_INVALID_REQUEST;
            $this->error_message = "Invalid Request.";
            return false;
        }

        // reserved method prefix
        if (substr($this->method,0,4) == 'rpc.') {
            $this->error_code = self::ERROR_RESERVED_PREFIX;
            $this->error_message = "Illegal method name; Method cannot start with 'rpc.'";
            return false;
        }

        // illegal method name
        if (!preg_match(self::VALID_FUNCTION_NAME, $this->method)) {
            $this->error_code = self::ERROR_INVALID_REQUEST;
            $this->error_message = "Invalid Request.";
            return false;
        }

        // mismatched json-rpc version
        if ($this->json_rpc != "2.0") {
            $this->error_code = self::ERROR_MISMATCHED_VERSION;
            $this->error_message = "Client/Server JSON-RPC version mismatch; Expected '2.0'";
            return false;
        }

        // valid request
        return true;
    }
1121729
public function getErrors()
    {
        $diff = array_diff_key($this->_properties, $this->_errors);

        return $this->_errors + (new Collection($diff))
            ->filter(function ($value) {
                return is_array($value) || $value instanceof EntityInterface;
            })
            ->map(function ($value) {
                return $this->_readError($value);
            })
            ->filter()
            ->toArray();
    }
1240152
public boolean hasFatalErrors() {
        for (final TopicErrorDatabase.ErrorType type : errorTypes) {
            if (TopicErrorDatabase.FATAL_ERROR_TYPES.contains(type)) {
                return true;
            }
        }

        return false;
    }
41723
public function validate(): bool
    {
        foreach ($this as $element) {
            if ($element instanceof HasValueValidationInterface) {
                $element->validate();
            }
        }
        return $this->errors()->empty();
    }
834369
protected function validate()
    {
        $rules = $this->mergeRules();

        if ( empty($rules) ) return true;

        $data = $this->attributes;

        $validator = Validator::make($data, $rules);
        $success = $validator->passes();

        if ( $success )
        {
            if ( $this->validationErrors->count() > 0 )
            {
                $this->validationErrors = new MessageBag;
            }
        } else
        {
            $this->validationErrors = $validator->messages();
            throw new ValidationErrorException($validator->messages());
        }

        $this->valid = true;

        return $success;
    }
1220525
public function error()
    {
        $errorNo = $_FILES[$this->file]['error'] ?? NULL;

        if( $errorNo === NULL )
        {
            return $this->getLang['upload:unknownError'];
        }

        if( is_array($errorNo) )
        {
            $errno = 0;

            foreach( $errorNo as $no )
            {
                if( ! empty($no) )
                {
                    $errno = $no;
                    break;
                }
            }

            $errorNo = $errno;
        }

        $lang = $this->getLang;

        $this->errors =
        [
            '0'  => "scc",            
            '1'  => $lang['upload:1'],
            '2'  => $lang['upload:2'], 
            '3'  => $lang['upload:3'], 
            '4'  => $lang['upload:4'], 
            '6'  => $lang['upload:6'], 
            '7'  => $lang['upload:7'], 
            '8'  => $lang['upload:8'], 
            '9'  => $lang['upload:9'],
            '10' => $lang['upload:10']
        ];
       
        if( ! empty($this->manuelError) )
        {
            return $this->errors[$this->manuelError];
        }
        elseif( ! empty($this->extensionControl) )
        {
            return $this->extensionControl;
        }
        elseif( ! empty($this->errors[$errorNo]) )
        {
            if( $this->errors[$errorNo] === "scc" )
            {
                return false;
            }
            return $this->errors[$errorNo];
        }
        else
        {
            return $lang['upload:unknownError'];
        }
    }
899779
public static function hasError() {
		$error        = json_last_error();
		$errorMessage = array_key_exists($error, self::$errors) ? self::$errors[$error] : "Unknown error ({$error})";
		return $errorMessage;
	}
313837
public function isValid()
    {
        $this->errorMessages = [];
        $this->validatorCollection->rewind();
        while ($this->validatorCollection->valid()) {
            $this->checkForErrors($this->validatorCollection->current());
            $this->validatorCollection->next();
        }
        $count = count($this->errorMessages);
        return $count == 0;
    }
751571
protected function getError()
	{
		return $this->form->error(
			$this->model,
			$this->attribute,
			$this->errorOptions,
			$this->enableAjaxValidation,
			$this->enableClientValidation
		);
	}
607029
public function isValid()
    {
        $result = true;
        $fields = $this->getFields();
        // Check each element for validators, validate them and return the result.
        foreach ($fields as $field) {
            if ($field->validate() == false) {
                $result = false;
            }
        }
        return $result;
    }
768650
public function getValidationErrors()
    {
        $fields = $this->getFields();
        if (!$fields) {
            return [];
        }

        $result = [];
        foreach ($fields as $field) {
            if ($field instanceof AbstractFormField) {
                if (!$field->isValid()) {
                    $result = array_merge($result, $field->getErrorMessages());
                }
            }
        }

        return $result;
    }
919734
public function hasErrorMessages() {
      $messages = $this->getMessages();
      foreach ($messages as $message) {
        if ($message->mt == 'error') {
          return true;
        }
      }
      return false;
    }
315442
public function getModelStaticValidationRules()
    {
        $model = $this->getDataModel();

        return isset($model::$rules) && is_array($model::$rules) ? $model::$rules : false;
    }
695510
public function getAllErrors()
    {
        $errors = $this->getErrors();

        $types = $this->getClasses()->merge($this->getInterfaces())->merge($this->getTraits());

        $elements = $this->getFunctions()->merge($this->getConstants())->merge($types);

        foreach ($elements as $element) {
            if (!$element) {
                continue;
            }

            $errors = $errors->merge($element->getErrors());
        }

        foreach ($types as $element) {
            if (!$element) {
                continue;
            }

            foreach ($element->getMethods() as $item) {
                if (!$item) {
                    continue;
                }

                $errors = $errors->merge($item->getErrors());
            }

            if (method_exists($element, 'getConstants')) {
                foreach ($element->getConstants() as $item) {
                    if (!$item) {
                        continue;
                    }

                    $errors = $errors->merge($item->getErrors());
                }
            }

            if (method_exists($element, 'getProperties')) {
                foreach ($element->getProperties() as $item) {
                    if (!$item) {
                        continue;
                    }

                    $errors = $errors->merge($item->getErrors());
                }
            }
        }

        return $errors;
    }
1335403
protected function validateExtensionSettings()
    {
        $field = 'extension_limit';
        $rules = $this->getSubmitted($field);

        $errors = $converted = array();
        foreach (gplcart_string_explode_multiline($rules) as $line => $rule) {

            $line++;

            $parts = gplcart_string_explode_whitespace($rule, 2);

            if (count($parts) != 2) {
                $errors[] = $line;
                continue;
            }

            list($role_id, $extensions) = $parts;

            if (!$this->isValidRoleSettings($role_id)) {
                $errors[] = $line;
                continue;
            }

            $filtered_extensions = array_filter(array_map('trim', explode(',', $extensions)));

            foreach ($filtered_extensions as $extension) {
                if (!ctype_alnum($extension) || strlen($extension) > 250) {
                    $errors[] = $line;
                    break;
                }
            }

            $converted[$role_id] = $filtered_extensions;
        }

        if (!empty($errors)) {
            $error = $this->translation->text('Error on line @num', array('@num' => implode(',', $errors)));
            $this->setError($field, $error);
            return false;
        }

        $this->setSubmitted($field, $converted);
        return true;
    }