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


PHP EmailAddress::getMessages方法代码示例

本文整理汇总了PHP中Zend\Validator\EmailAddress::getMessages方法的典型用法代码示例。如果您正苦于以下问题:PHP EmailAddress::getMessages方法的具体用法?PHP EmailAddress::getMessages怎么用?PHP EmailAddress::getMessages使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Zend\Validator\EmailAddress的用法示例。


在下文中一共展示了EmailAddress::getMessages方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testUseMxRecordsBasicInvalid

    /**
     * @group ZF2-130
     */
    public function testUseMxRecordsBasicInvalid()
    {
        $validator = new EmailAddress(array(
            'useMxCheck'        => true,
            'useDeepMxCheck'    => true
        ));

        $emailAddresses = array(
            '',
            'bob

            @domain.com',
            'bob jones@domain.com',
            '.bobJones@studio24.com',
            'bobJones.@studio24.com',
            'bob.Jones.@studio24.com',
            '"bob%jones@domain.com',
            'bob@verylongdomainsupercalifragilisticexpialidociousaspoonfulofsugar.com',
            'bob+domain.com',
            'bob.domain.com',
            'bob @domain.com',
            'bob@ domain.com',
            'bob @ domain.com',
            'Abc..123@example.com'
            );
        foreach ($emailAddresses as $input) {
            $this->assertFalse($validator->isValid($input), implode("\n", $this->validator->getMessages()) . $input);
        }
    }
开发者ID:benivaldo,项目名称:zf2-na-pratica,代码行数:32,代码来源:EmailAddressTest.php

示例2: validateEmail

 /**
  * Trims and validates email
  * 
  * @param string $email
  * @return string
  * @throws Exception
  */
 public static function validateEmail($email)
 {
     $validator = new EmailAddress();
     if (!$validator->isValid((new StringTrim())->filter($email))) {
         throw new Exception(Json::encode($validator->getMessages()));
     }
     return $email;
 }
开发者ID:parnustk,项目名称:lisbackend,代码行数:15,代码来源:Validator.php

示例3: validateEntity

 /**
  * {@inheritDoc}
  */
 public function validateEntity(EntityInterface $entity, ErrorStore $errorStore)
 {
     if (false == $entity->getName()) {
         $errorStore->addError('o:name', 'The name cannot be empty.');
     }
     $email = $entity->getEmail();
     $validator = new EmailAddress();
     if (!$validator->isValid($email)) {
         $errorStore->addValidatorMessages('o:email', $validator->getMessages());
     }
     if (!$this->isUnique($entity, ['email' => $email])) {
         $errorStore->addError('o:email', sprintf('The email "%s" is already taken.', $email));
     }
     if (false == $entity->getRole()) {
         $errorStore->addError('o:role', 'Users must have a role.');
     }
 }
开发者ID:patrova,项目名称:omeka-s,代码行数:20,代码来源:UserAdapter.php

示例4: __construct

 /**
  * Constructor
  *
  * @param  string $email
  * @param  null|string $name
  * @throws Exception\InvalidArgumentException
  * @return Address
  */
 public function __construct($email, $name = null)
 {
     $emailAddressValidator = new EmailAddressValidator(Hostname::ALLOW_DNS | Hostname::ALLOW_LOCAL);
     if (!is_string($email) || empty($email)) {
         throw new Exception\InvalidArgumentException('Email must be a valid email address');
     }
     if (preg_match("/[\r\n]/", $email)) {
         throw new Exception\InvalidArgumentException('CRLF injection detected');
     }
     if (!$emailAddressValidator->isValid($email)) {
         $invalidMessages = $emailAddressValidator->getMessages();
         throw new Exception\InvalidArgumentException(array_shift($invalidMessages));
     }
     if (null !== $name) {
         if (!is_string($name)) {
             throw new Exception\InvalidArgumentException('Name must be a string');
         }
         if (preg_match("/[\r\n]/", $name)) {
             throw new Exception\InvalidArgumentException('CRLF injection detected');
         }
         $this->name = $name;
     }
     $this->email = $email;
 }
开发者ID:ppiedaderawnet,项目名称:concrete5,代码行数:32,代码来源:Address.php

示例5: testHostnameSettings

   /**
     * Test changing hostname settings via EmailAddress object
     *
     * @return void
     */
    public function testHostnameSettings()
    {
        $validator = new Validator\EmailAddress();

        // Check no IDN matching
        $validator->getHostnameValidator()->setValidateIdn(false);
        $valuesExpected = array(
            array(false, array('name@b�rger.de', 'name@h�llo.de', 'name@h�llo.se'))
            );
        foreach ($valuesExpected as $element) {
            foreach ($element[1] as $input) {
                $this->assertEquals($element[0], $validator->isValid($input), implode("\n", $validator->getMessages()));
            }
        }

        // Check no TLD matching
        $validator->getHostnameValidator()->setValidateTld(false);
        $valuesExpected = array(
            array(true, array('name@domain.xx', 'name@domain.zz', 'name@domain.madeup'))
            );
        foreach ($valuesExpected as $element) {
            foreach ($element[1] as $input) {
                $this->assertEquals($element[0], $validator->isValid($input), implode("\n", $validator->getMessages()));
            }
        }
    }
开发者ID:rkeplin,项目名称:zf2,代码行数:31,代码来源:EmailAddressTest.php

示例6: testUseMxCheckBasicValid

 /**
  * @group ZF2-130
  */
 public function testUseMxCheckBasicValid()
 {
     $validator = new Validator\EmailAddress(array('useMxCheck' => true, 'useDeepMxCheck' => true));
     $emailAddresses = array('bob@gmail.com', 'bob.jones@bbc.co.uk', 'bob.jones.smythe@bbc.co.uk', 'BoB@aol.com', 'bobjones@nist.gov', "B.O'Callaghan@usmc.mil", 'bob+jones@nic.us', 'bob+jones@dailymail.co.uk', 'bob@teaparty.uk.com', 'bob@thelongestdomainnameintheworldandthensomeandthensomemoreandmore.com');
     foreach ($emailAddresses as $input) {
         $this->assertTrue($validator->isValid($input), "{$input} failed to pass validation:\n" . implode("\n", $validator->getMessages()));
     }
 }
开发者ID:rafalwrzeszcz,项目名称:zf2,代码行数:11,代码来源:EmailAddressTest.php

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