respect-validation/library/Respect/Validation/Exceptions/AlnumException.php
2010-11-30 13:36:04 -02:00

25 lines
847 B
PHP

<?php
namespace Respect\Validation\Exceptions;
class AlnumException extends InvalidException
{
const MSG_NOT_ALPHANUMERIC = 'Alnum_1';
const MSG_NOT_ALPHANUMERIC_ADDITIONAL = 'Alnum_2';
protected $messageTemplates = array(
self::MSG_NOT_ALPHANUMERIC => '"%s" does not contains only letters and digits',
self::MSG_NOT_ALPHANUMERIC_ADDITIONAL => '"%s" does not contains only letters and digits (including "%s")'
);
public function __construct($input, $additionalChars='')
{
$code = empty($additionalChars) ? self::MSG_NOT_ALPHANUMERIC : self::MSG_NOT_ALPHANUMERIC_ADDITIONAL;
parent::__construct(
sprintf(
$this->getMessageTemplate($code),
$this->getStringRepresentation($input), $additionalChars
)
);
}
}