Field must end with a specific substring.

@param string $sub
@param string $message
@return FormValidator
336548
public function endsWith($sub, $message = null)
    {
        $this->setRule(__FUNCTION__, function($val, $args)
                       {
                           $sub = $args[0];
                           return (strlen($val) === 0 || substr($val, -strlen($sub)) === $sub);
                       }, $message, array($sub));
        return $this;
    }
1315814
public static function createMessage(string $message): string
    {
        $lastErrorMessage = error_get_last();
        if ($lastErrorMessage !== null) {
            $message .= "; ".$lastErrorMessage["message"];
        }
        return $message;
    }
778111
public function postFormSubmit(FormSubmitEvent $event)
    {
        $post = $event->getPost();
        $form = $post->getForm();

        if ($form->getNotificationEmail()) {
            $this->mailer->sendNotificationMail($form, $post);
        }

        if ($form->requiresConfirmation()) {
            foreach ($post->getValueSet()->getValues() as $value) {
                if ($value instanceof EmailValue && !empty($value->getValue())) {
                    $this->mailer->sendConfirmationMail($form, $post, $value->getValue());
                }
            }
        }
    }
1283242
public function message($message)
    {
        if(trim($message))
        {
            $msg = new stdClass();
            $msg->type = 'text';
            $msg->message = $message;
            $this->messages[] = $msg;
        }        
    }
773717
protected function stringifyMessage($message)
    {
        if (is_array($message) || is_object($message) || is_bool($message)) {
            return (string)var_export($message, true);
        }
        return (string)$message;
    }
1217769
protected function addSender($mailMessage, $message)
    {
        if (! empty($message->from)) {
            $mailMessage->from($message->from[0], Arr::get($message->from, 1));
        }

        if (! empty($message->replyTo)) {
            foreach ($message->replyTo as $replyTo) {
                $mailMessage->replyTo($replyTo[0], Arr::get($replyTo, 1));
            }
        }
    }
187240
private function validateAgainstExpression( $field, $value, $rule, $message = null )
    {
        if (preg_match($this->expressions[ $rule ], $value)) {
            return true;
        }

        if (!$message) {
            $message = $this->error_messages[ $rule ];
        }

        static::$errors[ $field ] = $message;

        return false;
    }
1359012
public function resolveCustomMessage($message)
    {
        preg_match_all('/\{[\w.| ]+\}/', $message, $segments);
        foreach (current($segments) as $segment) {
            $s    = str_replace(['{', '}'], '', $segment);
            $keys = explode('|', $s);

            if (empty($keys[1]) && isset($keys[2])) {
                $keys[1] = $this->callback($keys[2]);
            }

            $valueSegmented = $this->getValueSegmented($this, $keys[0], isset($keys[1]) ? $keys[1] : false);
            if (!$valueSegmented) {
                return false;
            }
            $message = str_replace($segment, $valueSegmented, $message);
        }

        return $message;
    }
1096224
public function DefineLocation($Message) {
      $Controller = GetValue('Controller', $Message);
      $Application = GetValue('Application', $Message);
      $Method = GetValue('Method', $Message);
      
      if (in_array($Controller, $this->_SpecialLocations)) {
         SetValue('Location', $Message, $Controller);
      } else {
         SetValue('Location', $Message, $Application);
         if (!StringIsNullOrEmpty($Controller)) 
            SetValue('Location', $Message, GetValue('Location', $Message).'/'.$Controller);
         if (!StringIsNullOrEmpty($Method)) 
            SetValue('Location', $Message, GetValue('Location', $Message).'/'.$Method);
      }
      
      return $Message;
   }
1235031
public static function createFromRaw($message)
    {
        $eventStart = strpos($message, 'Event: ') + 7;
        $eventEnd = strpos($message, Message::EOL, $eventStart);
        if ($eventEnd === false) {
            $eventEnd = strlen($message);
        }
        $name = substr($message, $eventStart, $eventEnd - $eventStart);
        $parts = explode('_', $name);
        $totalParts = count($parts);
        for ($i = 0; $i < $totalParts; $i++) {
            $parts[$i] = ucfirst($parts[$i]);
        }
        $name = implode($parts, '');
        $className = '\\PAMI\\Message\\Event\\' . $name . 'Event';
        if (class_exists($className, true)) {
            return new $className($message);
        }
        return new UnknownEvent($message);
    }
30072
public function required($message = null)
    {
        $this->setRule(__FUNCTION__, function($val)
                       {
                           if (is_scalar($val)) {
                               $val = trim($val);
                           }
                           return !empty($val);
                       }, $message);
        return $this;
    }
334273
public function addValidationMessage($rule, $message)
    {
        if (($pos = strpos($rule, ':')) !== false) {
            $rule = substr($rule, 0, $pos);
        }

        $this->validationMessages[$rule] = $message;

        return $this;
    }
891950
public function validate(Message $message)
    {
        if ($message->getBodyWrapLength() > self::WRAP_LIMIT) {
            $message->addStatus(new LimitTheBodyWrapLengthTo72CharactersStatus());
        }
    }
818964
static public function endsWith($string, $needle, $message = null, $propertyPath = null, $encoding = 'utf8')
        {
            static::string($string);

            $stringPosition = mb_strlen($string, $encoding) - mb_strlen($needle, $encoding);

            if (mb_strripos($string, $needle, null, $encoding) !== $stringPosition) {
                $message = $message ?: sprintf(
                    'Value "%s" does not end with "%s".',
                    static::stringify($string),
                    static::stringify($needle)
                );

                $constraints = array('needle' => $needle, 'encoding' => $encoding);

                throw static::createException($string, $message, static::INVALID_STRING_END, $propertyPath, $constraints);
            }
        }
1356219
public function isNotNull($message = null, $subProperty = null)
    {
        $this->callback = function ($builder) use ($subProperty) {
            $builder = ($subProperty !== null && !empty($builder->{$subProperty}))
                        ? $builder->{$subProperty}
                        : $builder;
            if (!property_exists($builder, $this->target->property)
                && !isset($builder->{$this->target->property})
            ) {
                throw new BuilderException(
                    sprintf(
                        'Property `%s` does not exist on `%s`',
                        $this->target->property,
                        get_class($builder)
                    )
                );
            }
            $value = $builder->{$this->target->property};
            return null !== $value;
        };
        $this->message = !empty($message)
            ? $message
            // TODO: implement a way to expose property name
            : sprintf(
                '%s cannot be null for this transaction type.',
                $this->target->property
            );

        if ($this->precondition) {
            return $this->target;
        }

        return $this->parent->of($this->target->type, $this->target->modifier);
    }
210723
private function summarize($message)
    {
        $message = ltrim($message, "\n");
        if ($newLinePos = strpos($message, "\n")) {
            $message = substr($message, 0, $newLinePos);
        }

        return rtrim($message);
    }
680901
public function appendMessage($message)
    {
        $context = $this->_context;

        $context->messages[$message->field][] = $message;

        return $this;
    }