@param      $max
@param null $error_message

@return ValidateBuilder
@throws \Exception
507196
function ruleMax($max, $error_message = null) {
        if (!is_numeric($max)) {
            throw new \Exception('Incorrect parameter MAX in rule max');
        }

        return $this->_rule('max:' . $max, $error_message);
    }
207153
public function vLimit(Int $min = 0, Int $max = NULL)
    {
        $key['minchar'] = [':p1' => $min];
        $typ['minchar'] = $min;

        if( $max !== NULL )
        {
            $key['maxchar'] = [':p1' => $max];
            $typ['maxchar'] = $max;
        }

        return $this->onInvalidEventPattern('.{' . $min . ',' . $max . '}', $key, [], $typ);
    }
1371407
final public function setErrorMessage($message)
    {
        $this->errorMessage = (string) $message;

        if (empty($this->errorMessage)) {
            throw new \RuntimeException('Error message cannot be empty !');
        }

        return $this;
    }
793826
public function exception($exception, $user_message=null) {
	if ($exception instanceof \Exception == false) {
		return $this->error('unknown exception format', response::STATUS_INTERNAL_SERVER_ERROR);
	}
	
	$exception_class = bootstrap::get_library('exception');
	
	$this->data['exception']['current'] = $exception;
	$this->data['exception']['current_trace_string'] = $exception_class::clean_paths(nl2br($exception->getTraceAsString()));
	
	$previous = $exception->getPrevious();
	if ($previous) {
		$this->data['exception']['previous'] = $previous;
		$this->data['exception']['previous_trace_string'] = $exception_class::clean_paths(nl2br($previous->getTraceAsString()));
	}
	
	$reason = $exception->getMessage();
	$code   = $exception->getCode();
	$this->error($reason, $code, $user_message);
}
363834
protected function buildErrors()
    {
        if ($this->hasErrors()) {
            echo implode(PHP_EOL, $this->getErrors());
            echo PHP_EOL, $this->opts->getUsageMessage();
        }

        return $this;
    }
130534
private function encodeFault($error_code, $error_message) {

        $value = htmlentities($error_message, ENT_QUOTES, $this->encoding, false);

        $string = preg_replace_callback('/&([a-zA-Z][a-zA-Z0-9]+);/S', 'self::numericEntities', $value);

        $payload = "<fault>";
        $payload .= "<value>";
        $payload .= "<struct>";
        $payload .= "<member>";
        $payload .= "<name>faultCode</name>";
        $payload .= "<value><int>".$error_code."</int></value>";
        $payload .= "</member>";
        $payload .= "<member>";
        $payload .= "<name>faultString</name>";
        $payload .= "<value><string>".$string."</string></value>";
        $payload .= "</member>";
        $payload .= "</struct>";
        $payload .= "</value>";
        $payload .= "</fault>";

        return $payload;

    }
632288
public function max($max, $message = null)
    {
        $this->set([
            'max' => (int)$max,
        ], $message);
        return $this;
    }
860351
public function messagesAction($max = self::MAX_MESSAGES)
    {
        if (!$this->getDispatcher()->hasListeners(ThemeEvents::THEME_MESSAGES)) {
            return new Response();
        }

        $listEvent = $this->getDispatcher()->dispatch(ThemeEvents::THEME_MESSAGES, new MessageListEvent());

        return $this->render(
                    'AvanzuAdminThemeBundle:Navbar:messages.html.twig',
                        [
                            'messages' => $listEvent->getMessages(),
                            'total' => $listEvent->getTotal(),
                        ]
        );
    }
1331110
public function reportError(
        Builder $builder,
        $plugin,
        $message,
        $severity = BuildError::SEVERITY_NORMAL,
        $file = null,
        $lineStart = null,
        $lineEnd = null
    ) {
        unset($builder);

        $error = new BuildError();
        $error->setBuild($this);
        $error->setCreatedDate(new \DateTime());
        $error->setPlugin($plugin);
        $error->setMessage($message);
        $error->setSeverity($severity);
        $error->setFile($file);
        $error->setLineStart($lineStart);
        $error->setLineEnd($lineEnd);
        $error->hash();

        return Factory::getStore('BuildError')->save($error);
    }
639872
public function reportError(string $error_message) : void
    {
        $error_message = sprintf($error_message, $this->field_name);
        if (null != $this->validation_set) {
            $this->validation_set->addValidationError(new ValidationError($this->field_name, $error_message));
        }
    }
696188
public function setMaxLength(string $elementName, int $maxLength, string $errorMessage = null): \IvoPetkov\BearFrameworkAddons\Form\Constraints
    {
        if ($errorMessage === null) {
            $errorMessage = sprintf(__('ivopetkov.form.The length of this field must be atmost %s characters.'), $maxLength);
        }
        $this->data[] = ['maxLength', $errorMessage, $elementName, $maxLength];
        return $this;
    }
980354
protected function create_error_message( $message_name, $value ) {

		$message = $this->get_message_template( $message_name );

		if ( ! is_scalar( $value ) ) {
			$value = $this->get_value_as_string( $value );
		}

		// replacing the placeholder for the %value%
		$message = str_replace( '%value%', $value, $message );

		// replacing the possible options-placeholder on the message
		foreach ( $this->options as $search => $replace ) {
			$replace = $this->get_value_as_string( $replace );
			$message = str_replace( '%' . $search . '%', $replace, $message );
		}

		return $message;
	}
1305595
public function validate($failOn = Validator\Rule::ERROR)
    {
        $this->warnings = [];
        $this->errors = [];

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

            if ($rule instanceof Validator\Condition) {
                // Condition

                $condition = $rule;
                if ($condition->validate()) {
                    // Conditions rules

                    if (!$condition->getValidator()->validate($failOn)) {

                        $this->errors = array_merge(
                            $this->errors,
                            $rule->getValidator()->getErrors()
                        );
                    }
                    $this->warnings = array_merge(
                        $this->warnings,
                        $rule->getValidator()->getWarnings()
                    );
                }
            } else {
                // Rule

                if (!$rule->validate()) {

                    if ($rule->getSeverity() <= $failOn) {
                        $this->errors[] = $rule;
                    } else {
                        $this->warnings[] = $rule;
                    }
                }
            }
        }

        // Run nested validators - every entity may have its own validator
        foreach ($this->entity->getData() as $propertyName => $value) {

            if ($value instanceof Entity) {

                $validator = $value->getValidator();

                if (!$validator->validate($failOn)) {

                    foreach ($validator->getErrors() as $error) {

                        $rule = clone $error;
                        $rule->setPath(
                            array_merge([$propertyName], $rule->getPath())
                        );
                        $this->errors[] = $rule;
                    }
                }

                foreach ($validator->getWarnings() as $warning) {

                    $rule = clone $warning;
                    $rule->setPath(
                        array_merge([$propertyName], $rule->getPath())
                    );
                    $this->warnings[] = $rule;
                }
            }
        }

        return count($this->errors) === 0;
    }
334164
public function setMax($max)
    {
        if (is_array($max) and isset($max['max'])) {
            $max = $max['max'];
        }

        if (!is_string($max) and !is_numeric($max)) {
            // require_once 'Zend/Validate/Exception.php';
            throw new Zend_Validate_Exception ('Invalid options to validator provided');
        }

        $max = (integer) $max;
        if (($this->_min !== null) && ($max < $this->_min)) {
            // require_once 'Zend/Validate/Exception.php';
            throw new Zend_Validate_Exception("The maximum must be greater than or equal to the minimum file count, but "
                                            . "$max < {$this->_min}");
        }

        $this->_max = $max;
        return $this;
    }
348478
public function validateRangeCheckboxesChecked($min_count, $max_count)
    {
        $this->validator_attributes[] = 'data-parsley-check="[' . (int)$min_count . ', ' . (int)$max_count . ']"';

        $this->validator_checks['min_checkboxes_checked'] = (int)$min_count;
        $this->validator_checks['max_checkboxes_checked'] = (int)$max_count;

        return $this;
    }
858476
static public function max($value, $maxValue, $message = null, $propertyPath = null)
        {
            static::integer($value);

            if ($value > $maxValue) {
                $message = $message ?: sprintf(
                    'Number "%s" was expected to be at most "%d".',
                    static::stringify($value),
                    static::stringify($maxValue)
                );

                throw static::createException($value, $message, static::INVALID_MAX, $propertyPath, array('max' => $maxValue));
            }
        }
38487
function message($rule, $error_message, $field = null) {
        $rule                                                 = explode(':', $rule);
        $rule                                                 = Arr::get($rule, 0);
        $this->messages[($field ? $field . '.' : '') . $rule] = $error_message;

        return $this;
    }