本文整理汇总了PHP中Zend\Validator\EmailAddress::setOptions方法的典型用法代码示例。如果您正苦于以下问题:PHP EmailAddress::setOptions方法的具体用法?PHP EmailAddress::setOptions怎么用?PHP EmailAddress::setOptions使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend\Validator\EmailAddress
的用法示例。
在下文中一共展示了EmailAddress::setOptions方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
public function __construct()
{
$validatorEmail = new EmailAddress();
$validatorEmail->setOptions(array('domain' => FALSE));
$this->add(array('name' => 'email', 'filters' => array(array('name' => 'StringTrim'), array('name' => 'StripTags')), 'validators' => array($validatorEmail, array('name' => 'NotEmpty', 'options' => array('messages' => array('isEmpty' => 'Digite corretamente o seu e-mail!'))))));
$this->add(array('name' => 'senha', 'required' => true, 'filters' => array(array('name' => 'StringTrim'), array('name' => 'StripTags'))));
}
示例2: testSetOptions
/**
* Testing setOptions
*/
public function testSetOptions()
{
$this->validator->setOptions(array('messages' => array(EmailAddress::INVALID => 'TestMessage')));
$messages = $this->validator->getMessageTemplates();
$this->assertEquals('TestMessage', $messages[EmailAddress::INVALID]);
$oldHostname = $this->validator->getHostnameValidator();
$this->validator->setOptions(array('hostnameValidator' => new Hostname(Hostname::ALLOW_ALL)));
$hostname = $this->validator->getHostnameValidator();
$this->assertNotEquals($oldHostname, $hostname);
}
示例3: validateAndCheckDiscountData
/**
* @param $data
* @param bool $reservationId
* @return array
*/
public function validateAndCheckDiscountData($data, $reservationId = false)
{
$result = ['valid' => false, 'message' => ''];
try {
if ($reservationId) {
/**
* @var \DDD\Dao\Booking\Booking $reservationDao
*/
$reservationDao = $this->getServiceLocator()->get('dao_booking_booking');
$reservationData = $reservationDao->getDataForDiscountValidationById($reservationId);
$data = ['email' => $reservationData->getGuestEmail(), 'aff_id' => $reservationData->getPartnerId()];
}
$visitor = new Container('visitor');
if (!isset($data['aff_id']) && !is_null($visitor->partnerId) && (int) $visitor->partnerId) {
$data['aff_id'] = (int) $visitor->partnerId;
}
$emailValidator = new EmailAddress();
$emailValidator->setOptions(['domain' => true]);
// validate Email for ginosiks
if (isset($data['aff_id']) && $data['aff_id'] == self::SECRET_DISCOUNT_AFFILIATE_ID) {
if (!isset($data['email']) || empty($data['email'])) {
$result['message'] .= "Email field is not submitted.\n";
} elseif (!$emailValidator->isValid($data['email'])) {
$result['message'] .= "Email not valid.\n";
} else {
/**
* @var UserManager $userManager
*/
$userManager = $this->getServiceLocator()->get('dao_user_user_manager');
$userRow = $userManager->getUserIdByEmailAddress($data['email']);
// validate User
if (!$userRow['id']) {
$result['message'] .= "Email does not match the Ginosi User.\n";
} elseif ($userRow['system'] != 0 || $userRow['disabled'] != 0) {
$result['message'] .= "User disabled or system.\n";
} else {
$result['email'] = strtolower($data['email']);
}
}
}
// validate Affiliate Id
if (!isset($data['aff_id']) || !is_numeric($data['aff_id'])) {
$result['message'] .= "Affiliate Id field is not submitted.\n";
} else {
$result['aff_id'] = (int) $data['aff_id'];
}
// get Affiliate Discount Value
if (isset($result['aff_id'])) {
/**
* @var PartnersDAO $partnerDao
*/
$partnerDao = $this->getServiceLocator()->get('dao_partners_partners');
$partnerData = $partnerDao->getPartnerNameAndDiscountById($result['aff_id']);
// check Affiliate Discount Value
if (empty($partnerData['discount']) && $partnerData['discount'] <= 0) {
$result['message'] .= "Affiliate does not have discounts.\n";
} else {
$result['discount_value'] = $partnerData['discount'];
$result['partner_name'] = $partnerData['partner_name'];
}
}
// final judgment
if (empty($result['message'])) {
$result['valid'] = true;
unset($result['message']);
}
} catch (\Exception $e) {
$this->gr2logException($e, 'Cannot validate and check reservation discount data', $data);
}
return $result;
}
示例4: getEmailValidator
public function getEmailValidator()
{
if ($this->emailValidator === NULL) {
$validator = new EmailAddress();
$validator->setOptions($this->getEmailConfig())->setMessages(array(EmailAddress::DOT_ATOM => $this->getErrorMessage('EMAILADDRESS::DOT_ATOM'), EmailAddress::INVALID => $this->getErrorMessage('EMAILADDRESS::INVALID'), EmailAddress::INVALID_FORMAT => $this->getErrorMessage('EMAILADDRESS::INVALID_FORMAT'), EmailAddress::INVALID_HOSTNAME => $this->getErrorMessage('EMAILADDRESS::INVALID_HOSTNAME'), EmailAddress::INVALID_LOCAL_PART => $this->getErrorMessage('EMAILADDRESS::INVALID_LOCAL_PART'), EmailAddress::INVALID_MX_RECORD => $this->getErrorMessage('EMAILADDRESS::INVALID_MX_RECORD'), EmailAddress::INVALID_SEGMENT => $this->getErrorMessage('EMAILADDRESS::INVALID_SEGMENT'), EmailAddress::LENGTH_EXCEEDED => $this->getErrorMessage('EMAILADDRESS::LENGTH_EXCEEDED'), EmailAddress::QUOTED_STRING => $this->getErrorMessage('EMAILADDRESS::QUOTED_STRING')));
$this->setEmailValidator($validator);
}
return $this->emailValidator;
}