Add a failed rule and error message to the collection.

@param  string  $attribute
@param  string  $rule
@param  array  $parameters
@return void
333842
public function addFailure($attribute, $rule, $parameters = [])
    {
        if (! $this->messages) {
            $this->passes();
        }

        $this->messages->add($attribute, $this->makeReplacements(
            $this->getMessage($attribute, $rule), $attribute, $rule, $parameters
        ));

        $this->failedRules[$attribute][$rule] = $parameters;
    }
916563
protected function getSizeMessage( $attribute, $rule, array $parameters )
	{
		$lowerRule = $this->snakeCase( $rule );
		$type = $this->getAttributeType( $attribute );

		$lowerRule .= ".{$type}";

		return $this->translator( $lowerRule, $rule, $attribute, $parameters );
	}
1345915
public function validate($attribute, $value, $parameters, $validator)
    {
        list ($name, $locale) = $this->getAttributeNameAndLocale($attribute);

        if ($this->isUnique($value, $name, $locale, $parameters)) {
            return true;
        }

        $this->addErrorsToValidator($validator, $parameters, $name, $locale);

        return false;
    }
1026957
protected function replaceBefore($message, $attribute, $rule, $parameters)
    {
        if (! (strtotime($parameters[0]))) {
            return str_replace(':date', $this->getAttribute($parameters[0]), $message);
        }

        return str_replace(':date', $parameters[0], $message);
    }
412389
protected function replaceBefore($message, $attribute, $rule, $parameters)
    {
        if (! strtotime($parameters[0])) {
            return str_replace(':date', $this->getDisplayableAttribute($parameters[0]), $message);
        }

        return str_replace(':date', $this->getDisplayableValue($attribute, $parameters[0]), $message);
    }
824244
protected function validateRequiredIf($attribute, $value, $parameters)
	{
		if ($parameters[1] == array_get($this->data, $parameters[0]))
		{
			return $this->validateRequired($attribute, $value);
		}

		return true;
	}
1294049
public function validateIn($attribute, $value, $parameters)
    {
        if (is_array($value) && $this->hasRule($attribute, 'Array')) {
            foreach ($value as $element) {
                if (is_array($element)) {
                    return false;
                }
            }

            return count(array_diff($value, $parameters)) === 0;
        }

        return ! is_array($value) && in_array((string) $value, $parameters);
    }
1200999
protected function validateRequiredIf($attribute, $value, $parameters)
    {
        $this->requireParameterCount(2, $parameters, 'required_if');

        $data = array_get($this->data, $parameters[0]);

        $values = array_slice($parameters, 1);

        if (in_array($data, $values)) {
            return $this->validateRequired($attribute, $value);
        }

        return true;
    }
1008541
protected function replaceRequiredIf($message, $attribute, $rule, $parameters)
	{
		$parameters[0] = $this->getAttribute($parameters[0]);

		return str_replace(array(':other', ':value'), $parameters, $message);
	}
830801
public function termsValidator( $attribute, $params ) {

		if( $this->terms === 'on' ) {

			return;
		}

		if( !isset( $this->terms ) || $this->terms <= 0 ) {

			$this->addError( $attribute, Yii::$app->coreMessage->getMessage( CoreGlobal::ERROR_TERMS ) );
		}
	}
1049896
protected function doReplacements( $message, $attribute, $rule, $parameters )
	{
		$value = $this->getAttribute( $attribute );

		$message = str_replace( [':attribute', ':ATTRIBUTE', ':Attribute'], [
			$value,
			Str::upper( $value ),
			Str::ucfirst( $value )
		], $message );

		if ( isset( $this->replacers[Str::snake( $rule )] ) )
		{
			$message = $this->callReplacer( $message, $attribute, Str::snake( $rule ), $parameters );
		}
		elseif ( method_exists( $this, $replacer = "replace{$rule}" ) )
		{
			$message = $this->$replacer( $message, $attribute, $rule, $parameters );
		}

		return $message;
	}
394374
protected function doReplacements($message, $attribute, $rule, $parameters)
    {
        $message = str_replace(':attribute', $this->getAttribute($attribute), $message);

        $replacer = Str::snake($rule);

        if (isset($this->replacers[$replacer])) {
            $message = $this->callReplacer($message, $attribute, $replacer, $parameters);
        } else if (method_exists($this, $replacer = "replace{$rule}")) {
            $message = call_user_func(array($this, $replacer), $message, $attribute, $rule, $parameters);
        }

        return $message;
    }
121874
protected function addError($attribute, $message)
    {
        if (!isset($this->errors[$attribute])) {
            $this->errors[$attribute] = array();
        }
        $this->errors[$attribute][] = $message;
    }
9843
protected function validateDateFormat($attribute, $value, $parameters)
    {
        $this->requireParameterCount(1, $parameters, 'date_format');

        $parsed = date_parse_from_format($parameters[0], $value);

        return $parsed['error_count'] === 0 && $parsed['warning_count'] === 0;
    }
1100934
protected function replaceInArray( $message, $attribute, $rule, $parameters )
	{
		return str_replace( ':other', $this->getAttribute( $parameters[0] ), $message );
	}
56391
protected function replaceRequiredWithout($message, $attribute, $rule, $parameters)
    {
        return $this->replaceRequiredWith($message, $attribute, $rule, $parameters);
    }
1232215
protected function validate($attribute, $rule)
    {
        list($rule, $parameters) = $this->parseRule($rule);

        $value = $this->getValue($attribute);
        $method = 'validate' . self::studly($rule);

        if ($rule != 'required' && $value === null) {
            return true;
        }
        if (!$this->$method($attribute, $value, $parameters)) {
            if (in_array($rule, ['max', 'min', 'size', 'between'])) {
                $message = $this->ruleMessages[$rule][$this->getType($value)];
            } else {
                $message = $this->ruleMessages[$rule];
            }

            if (isset($this->customMessages[$attribute])) {
                $customMessage = $this->customMessages[$attribute];
                if (is_array($customMessage) && isset($customMessage[$rule])) {
                    $message = $customMessage[$rule];
                } else if (is_string($customMessage)){
                    $message = $customMessage;
                }
            }

            if ($rule == 'size') {
                $message = str_replace(':size', $parameters[0], $message);
            } else if ($rule == 'max') {
                $message = str_replace(':max', $parameters[0], $message);
            } else if ($rule == 'min') {
                $message = str_replace(':min', $parameters[0], $message);
            } else if ($rule == 'between') {
                $message = strtr($message, [':min' => $parameters[0], ':max' => $parameters[1]]);
            } else if ($rule == 'in') {
                $message = str_replace(':values', implode(',', $parameters), $message);
            } else if ($rule == 'contain') {
                $message = str_replace(':phrase', $parameters[0], $message);
            } else if ($rule == 'date_format') {
                $message = str_replace(':date_format', $parameters[0], $message);
            }

            if (isset($this->attributes[$attribute])) {
                $attribute = $this->attributes[$attribute];
            }
            $message = str_replace(':attribute', $attribute, $message);
            $this->message = $message;

            return false;
        }

        return true;
    }