public static function regex($value, $pattern, $message = null, $propertyPath = null)
{
static::string($value, $message, $propertyPath);
if (!preg_match($pattern, $value)) {
$message = sprintf($message ?: 'Value "%s" does not match expression.', static::stringify($value));
throw static::createException($value, $message, static::INVALID_REGEX, $propertyPath, array('pattern' => $pattern));
}
return true;
}