Sets template of validation failure message to be inserted at end of
validation failure message map.

Use null to specify no message should be inserted.

@param string|null $postMessage
@return self
778131
public function setPostMessageTemplate($postMessage = null)
    {
        if (null !== $postMessage) {
            $postMessage = (string) $postMessage;
        }
        $this->abstractOptions['messageTemplates']
                              [self::POST_MESSAGE_TEMPLATE_KEY] = $postMessage;
        return $this;
    }
1353630
public function addMessage($item, $message = null)
    {
        if ($message === null || $message === '') {
            return $this;
        }
        if (!array_key_exists($item, $this->messages)) {
            $this->messages[$item] = array();
        }
        $this->messages[$item][] = $message;

        return $this;
    }
1054368
protected function throwNewInvalidArgumentException ($errorMsg) {
		$selfClass = version_compare(PHP_VERSION, '5.5', '>') ? self::class : __CLASS__;
		$str = '['.$selfClass.'] ' . $errorMsg . ' (';
		if ($this->form) {
			$str .= 'form id: `'.$this->form->GetId() . '`, '
				. 'form type: `'.get_class($this->form).'`, ';
		}
		$str .= 'field type: `'.get_class($this) . '`)';
		throw new \InvalidArgumentException($str);
	}
1110808
public function setValidator(string $name, callable $callback, string $message = ''): self
    {
        if ($name = \trim($name)) {
            $this->_validators[$name] = $callback;

            if ($message) {
                $this->setMessage($name, $message);
            }
        }

        return $this;
    }
261361
public function validateNotNULL($msg = null)
    {
        $this->setMandatory();
        if ($msg && $msg !== true) {
            $msg = $this->app->_($msg);
        } else {
            $msg = sprintf($this->app->_('%s is a mandatory field'), $this->caption);
        }
        $this->validateField(array($this, '_validateNotNull'), $msg);

        return $this;
    }
950340
public function setMessage($message)
    {
        if ( ! is_null($message)) $message = (string) $message;

        $this->setAttribute('message', $message);

        return $this;
    }
630123
private function assertFormHasValidationMessage($expectedMessage)
    {
        Assert::true(
            $this->createPage->hasFormValidationError($expectedMessage),
            sprintf(
                'The validation message "%s" was not found on the page.',
                $expectedMessage
            )
        );
    }
987546
public function getMessageValidator(): ValidateMessage
    {
        $messageValidator = new ValidateMessageImplementation(
            [
                new CapitalizeTheSubjectLineValidator(),
                new DoNotEndTheSubjectLineWithAPeriodValidator(),
                new LimitTheBodyWrapLengthTo72CharactersValidator(),
                new LimitTheTitleLengthTo69CharactersValidator(),
                new SeparateSubjectFromBodyWithABlankLineValidator(),
                new SoftLimitTheTitleLengthTo50CharactersValidator(),
            ]
        );

        return $messageValidator;
    }
1168555
public function publishSystemTemplate($templateMessage) {
    	try{
			if (empty($templateMessage))
				throw new Exception('Paramer "templateMessage" is required');


    		$params = json_decode($templateMessage,TRUE);

    		$ret = $this->SendRequest->curl('/message/system/publish_template.json',$params,'json','im','POST');
    		if(empty($ret))
    			throw new Exception('bad request');
    		return $ret;

    	}catch (Exception $e) {
    		print_r($e->getMessage());
    	}
   }
472442
public function set_error_message($rule, $msg)
	{
		empty($rule) and $rule = 0;
		$this->error_messages[$rule] = strval($msg);

		return $this;
	}
35122
protected function validationResult($message, $field = null)
    {
        $error = ValidationResult::create()
            ->addFieldError($field, $message);
        return new ValidationException($error);
    }
108713
public function addErrorMessage(string $message) : self
    {
        if ($this->throw_errors == true) {
            throw new \RuntimeException($message);
        }

        $this->errors_messages[] = $message;
        return $this;
    }
800978
protected function addError($name, $customMessage = null)
    {
        $this->errors[$name] = $customMessage ?: $this->message ?: $this->{$name . 'Message'};
    }
1129615
public function assert(callable $validation, string $messageId = null, array $parameters = [])
    {
        return $this->validate(new CustomFormValidator($validation, $messageId, $parameters));
    }
43159
public function setValidation($param, $validation) {
// supprime les parentaises pour eviter les captures innattendus
        $validation = \preg_replace('`\((?=[^?][^:])`', '(?:', $validation);
        $this->Validations[$param] = $validation;
        return $this;
    }
1276539
private function build_message( array $input_data = [ ], $error_template ) {

		if ( ! substr_count( $error_template, '%' ) ) {
			return $error_template;
		}

		array_key_exists( 'value', $input_data ) or $input_data[ 'value' ] = NULL;

		// replacing the placeholder for the %value%
		$message = str_replace( '%value%', $this->as_string( $input_data[ 'value' ] ), $error_template );
		unset( $input_data[ 'value' ] );

		// replacing the placeholder for the %key%
		$data_key = isset( $input_data[ 'key' ] ) ? $input_data[ 'key' ] : '';
		array_key_exists( $data_key, $this->key_labels ) and $data_key = $this->key_labels[ $data_key ];
		$message = str_replace( '%key%', $this->as_string( $data_key ), $message );
		unset( $input_data[ 'key' ] );

		// replacing the possible options-placeholder on the message
		foreach ( $input_data as $key => $replace ) {
			is_numeric( $key ) or $message = str_replace( '%' . $key . '%', $this->as_string( $replace ), $message );
		}

		return $message;

	}
1184986
public function setPreMessageTemplate($template = null)
    {
        if (null !== $template) {
            $template = (string) $template;
        }
        $this->abstractOptions['messageTemplates']
                              [self::PRE_MESSAGE_TEMPLATE_KEY] = $template;
        return $this;
    }