本文整理汇总了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());
}