本文整理匯總了PHP中Zend\Validator\EmailAddress::setMessages方法的典型用法代碼示例。如果您正苦於以下問題:PHP EmailAddress::setMessages方法的具體用法?PHP EmailAddress::setMessages怎麽用?PHP EmailAddress::setMessages使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Zend\Validator\EmailAddress
的用法示例。
在下文中一共展示了EmailAddress::setMessages方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: testSettingHostnameMessagesThroughEmailValidator
/**
* @group ZF-7490
*/
public function testSettingHostnameMessagesThroughEmailValidator()
{
$translations = array(
'hostnameIpAddressNotAllowed' => 'hostnameIpAddressNotAllowed translation',
'hostnameUnknownTld' => 'hostnameUnknownTld translation',
'hostnameDashCharacter' => 'hostnameDashCharacter translation',
'hostnameInvalidHostnameSchema' => 'hostnameInvalidHostnameSchema translation',
'hostnameUndecipherableTld' => 'hostnameUndecipherableTld translation',
'hostnameInvalidHostname' => 'hostnameInvalidHostname translation',
'hostnameInvalidLocalName' => 'hostnameInvalidLocalName translation',
'hostnameLocalNameNotAllowed' => 'hostnameLocalNameNotAllowed translation',
);
$this->validator->setMessages($translations);
$this->validator->isValid('_XX.!!3xx@0.239,512.777');
$messages = $this->validator->getMessages();
$found = false;
foreach ($messages as $code => $message) {
if (array_key_exists($code, $translations)) {
$this->assertEquals($translations[$code], $message);
$found = true;
break;
}
}
$this->assertTrue($found);
}
示例2: __construct
public function __construct($name = null)
{
$hostNameValidator = new Validator\Hostname();
$hostNameValidator->setMessages(array(Validator\Hostname::INVALID => "Неверный тип поля", Validator\Hostname::LOCAL_NAME_NOT_ALLOWED => "", Validator\Hostname::UNKNOWN_TLD => "Неопознанное имя хоста", Validator\Hostname::INVALID_HOSTNAME => "Некорректно задано имя хоста", Validator\Hostname::CANNOT_DECODE_PUNYCODE => "", Validator\Hostname::INVALID_DASH => "", Validator\Hostname::INVALID_HOSTNAME_SCHEMA => "", Validator\Hostname::INVALID_LOCAL_NAME => "", Validator\Hostname::INVALID_URI => "", Validator\Hostname::IP_ADDRESS_NOT_ALLOWED => "", Validator\Hostname::UNDECIPHERABLE_TLD => ""));
$validator = new Validator\EmailAddress(array('hostnameValidator' => $hostNameValidator));
$validator->setMessages(array(Validator\EmailAddress::INVALID => "Неверный тип поля", Validator\EmailAddress::INVALID_FORMAT => "Неверный формат поля. Используйте стандартный формат local-part@hostname", Validator\EmailAddress::INVALID_HOSTNAME => "'%hostname%' некорректное имя хоста для email адреса", Validator\EmailAddress::INVALID_LOCAL_PART => "'%localPart%' некорректное имя для email адреса", Validator\EmailAddress::LENGTH_EXCEEDED => "Значение превышает допустимые размеры поля", Validator\EmailAddress::INVALID_MX_RECORD => "", Validator\EmailAddress::INVALID_SEGMENT => "", Validator\EmailAddress::DOT_ATOM => "", Validator\EmailAddress::QUOTED_STRING => ""));
$this->getValidatorChain()->attach($validator, true);
parent::__construct($name);
}
示例3: testIdenticalAndNonIdenticalMessagesReturned
public function testIdenticalAndNonIdenticalMessagesReturned()
{
$validator = new EmailAddress();
$this->assertFalse($validator->isValid('invalid@email.coma'));
$this->assertCount(3, $validator->getMessages());
$this->assertArrayHasKey(EmailAddress::INVALID_HOSTNAME, $validator->getMessages());
$this->assertArrayHasKey(Hostname::UNKNOWN_TLD, $validator->getMessages());
$this->assertArrayHasKey(Hostname::LOCAL_NAME_NOT_ALLOWED, $validator->getMessages());
$validator->setMessages(array(EmailAddress::INVALID_HOSTNAME => 'This is the same error message', Hostname::UNKNOWN_TLD => 'This is the same error message'));
$this->assertFalse($validator->isValid('invalid@email.coma'));
$this->assertCount(2, $validator->getMessages());
$this->assertArrayHasKey(EmailAddress::INVALID_HOSTNAME, $validator->getMessages());
$this->assertArrayHasKey(Hostname::LOCAL_NAME_NOT_ALLOWED, $validator->getMessages());
}