failure validation, add custom messages

@param array | String $attribute
@param String $message
@return boolean
514598
protected function failure($attribute, $message = null)
    {
        $this->deleteTemporaries($this->directory);
        $this->setCustomMessages([$attribute => trans($message)]);
        $this->addFailure($attribute, $attribute, []);
        return false;
    }
340808
protected function replaceRequiredUnless($message, $attribute, $rule, $parameters)
    {
        $other = $this->getDisplayableAttribute($parameters[0]);

        $values = [];

        foreach (array_slice($parameters, 1) as $value) {
            $values[] = $this->getDisplayableValue($parameters[0], $value);
        }

        return str_replace([':other', ':values'], [$other, implode(', ', $values)], $message);
    }
772789
public function rulePassword($attribute, $message)
    {
        if ($this->password != $this->$attribute) {
            $this->addError($attribute, $message);
        }
    }
1151798
protected function addError($property, $message)
    {
        $this->validationErrors->forProperty($property)->addError(new Error($message, time()));
    }
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);
    }
1235429
public function validateEmail( $attribute, $params ) {

		if( !$this->hasErrors() ) {

			if( $this->userService->isExistByEmail( $this->email ) ) {

				$this->addError( $attribute, Yii::$app->coreMessage->getMessage( CoreGlobal::ERROR_EMAIL_EXIST ) );
			}
		}
	}
341916
public function setAttributeMessage(string $name, string $message)
    {
        $this->messages['custom'][$name] = $message;
        return $this;
    }
552844
protected function validateAttribute (string $attribute=NULL) : bool
	{
		if (!property_exists($this, $attribute))
		{
			$this->error = "Attribute: ".ucfirst($attribute)." is not a class object.";
        	return FALSE;
		}
        $result = (is_array($this->$attribute)) ? !empty($this->$attribute) : Validate::hasValue($this->$attribute);
        if ($result) return TRUE;
		$this->error = "Set ".ucfirst($attribute)." to log your message.";
    	return FALSE;
	}
1224071
public function validateAttribute($model, $attribute)
    {
        $countries = [];
        if ($this->country !== null) {
            $countries = [$this->country];
        } elseif ($this->countryAttribute !== null) {
            $countries = [$model->{$this->countryAttribute}];
        } elseif (is_array($this->countries) && count($this->countries) > 0) {
            $countries = $this->countries;
        }

        if (count($countries) <= 0) {
            $countries = self::getPhoneUtil()->getSupportedRegions();
        }

        foreach ($countries as $country) {
            try {
                $number = self::getPhoneUtil()->parse($model->$attribute, $country);

                if (self::getPhoneUtil()->isValidNumberForRegion($number, $country)) {
                    if ($this->format) {
                        $model->$attribute = self::getPhoneUtil()->format($number, PhoneNumberFormat::INTERNATIONAL);
                    }

                    $this->_successValidation = true;
                    break;
                }
            } catch (NumberParseException $e) {
                $this->addError($model, $attribute, $this->numberParseExceptionMessage);
            }
        }

        if (!$this->_successValidation) {
            $this->addError($model, $attribute, $this->notValidPhoneNumberMessage);
        }

        return $this->_successValidation;
    }
56391
protected function replaceRequiredWithout($message, $attribute, $rule, $parameters)
    {
        return $this->replaceRequiredWith($message, $attribute, $rule, $parameters);
    }
1216922
protected function addError($object, $attribute, $message, $params = [])
    {
        $params['{attribute}'] = $object->getAttributeLabel($attribute);
        $object->addError($attribute, str_cover($message, $params));
    }
778610
protected function validateRequired( $attribute, $value )
	{
		if ( is_null( $value ) )
		{
			return false;
		}
		elseif ( is_string( $value ) && trim( $value ) === '' )
		{
			return false;
		}
		elseif ( ( is_array( $value ) || $value instanceof Countable ) && count( $value ) < 1 )
		{
			return false;
		}
		elseif ( $value instanceof File )
		{
			return (string) $value->getPath() != '';
		}

		return true;
	}
392952
public function validate(Validation $validation, $attribute)
    {
        $includeCountryCode = $this->getOption('must_include_country_code', false);
        $includePlus = $this->getOption('must_include_plus', false);
        $pattern = '/^' . '[+]' . (($includePlus) ? '' : '?') . (($includeCountryCode) ? '234[0]?' : '((234[0]?)|0)') . '[\d]{10}$/';
        $this->setOption('pattern', $pattern);

        if (!preg_match($pattern, $validation->getValue($attribute))) {
            $this->addMessageToValidation($validation, 'Invalid :field supplied', $attribute, 'NigerianPhoneNumber');
            return false;
        } else {
            return true;
        }
    }
89200
protected function addIteratedValidationMessages($attribute, $messages = [])
    {
        foreach ($messages as $field => $message) {
            $field_name = $attribute.$field;
            $messages[$field_name] = $message;
        }
        $this->setCustomMessages($messages);
    }
908834
protected function getErrorMessage($laravelRule, $attribute)
	{
		// getting user friendly attribute name
		$attribute = $this->getAttributeName($attribute);
		$message = Lang::get('validation.'.$laravelRule, ['attribute' => $attribute]);

		return ['data-msg-'.$laravelRule => $message];
	}
851467
public function addOnBlank($attribute, $msg)
	{
		if (!$msg)
			$msg = self::$DEFAULT_ERROR_MESSAGES['blank'];

		if (($value = $this->model->$attribute) === '' || $value === null)
			$this->add($attribute, $msg);
	}
914967
protected function validateBoolean( $attribute, $value )
	{
		if ( !$this->hasAttribute( $attribute ) )
		{
			return true;
		}

		$acceptable = [true, false, 0, 1, '0', '1'];

		return is_null( $value ) || in_array( $value, $acceptable, true );
	}