当前位置: 首页>>代码示例>>PHP>>正文


PHP EmailAddress::setMessages方法代码示例

本文整理汇总了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);
    }
开发者ID:benivaldo,项目名称:zf2-na-pratica,代码行数:30,代码来源:EmailAddressTest.php

示例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);
 }
开发者ID:t4web,项目名称:base,代码行数:9,代码来源:Email.php

示例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());
 }
开发者ID:pnaq57,项目名称:zf2demo,代码行数:14,代码来源:AbstractTest.php


注:本文中的Zend\Validator\EmailAddress::setMessages方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。