````php
$pattern = '/^[^' . preg_quote(implode($this->getValidCharacters()) . ']$/');
if (preg_match($pattern), $message) {
 // it contains invalid characters
 return false;
}