當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。