本文整理汇总了PHP中Nette\Utils\Validators::isEmail方法的典型用法代码示例。如果您正苦于以下问题:PHP Validators::isEmail方法的具体用法?PHP Validators::isEmail怎么用?PHP Validators::isEmail使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Nette\Utils\Validators
的用法示例。
在下文中一共展示了Validators::isEmail方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: execute
protected function execute(InputInterface $input, OutputInterface $output)
{
/** @var QuestionHelper $questionHelper */
$questionHelper = $this->getHelper('question');
$usernameQuestion = new Question('E-mail: ');
$usernameQuestion->setValidator(function ($value) {
if (trim($value) === '') {
throw new \Exception('E-mail can not be empty');
}
if (!Validators::isEmail($value)) {
throw new \Exception('E-mail is not valid');
}
return $value;
});
$passwordQuestion = new Question('Password: ');
$passwordQuestion->setValidator(function ($value) {
if (trim($value) === '') {
throw new \Exception('The password can not be empty');
}
return $value;
});
$passwordQuestion->setHidden(TRUE);
$passwordQuestion->setHiddenFallback(FALSE);
$username = $questionHelper->ask($input, $output, $usernameQuestion);
$password = $questionHelper->ask($input, $output, $passwordQuestion);
$name = $questionHelper->ask($input, $output, new Question('Name: '));
$user = $this->userFacade->add($username, $password, $name);
$output->writeln('User ' . $user->getEmail() . ' was successfully created!');
}
示例2: signUpFormValidated
function signUpFormValidated(\Nette\Forms\BootstrapUIForm $form)
{
$userCorrects = preg_match("/^[abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_]{4,40}\$/", $form->getValues()->username, $userTest);
$member = new \App\Model\MemberModel($this->database);
$userExists = $member->getUserName($form->values->username);
$emailExists = $member->getEmail($form->values->email);
$formVal = $form->getValues(TRUE);
if ($userExists > 0) {
unset($formVal["username"]);
$this->presenter->flashMessage('Uživatelské jméno již existuje', 'error');
} elseif (\Nette\Utils\Validators::isEmail($form->values->email) == FALSE) {
unset($formVal["email"]);
$this->presenter->flashMessage('Neplatná e-mailová adresa', 'error');
} elseif ($emailExists > 0) {
unset($formVal["email"]);
$this->presenter->flashMessage('E-mail již existuje', 'error');
} elseif ($userTest == 0) {
unset($formVal["username"]);
$this->presenter->flashMessage('Uživatelské jméno obsahuje nepovolené znaky', 'error');
} elseif (strlen($form->values->name) < 2) {
$this->presenter->flashMessage('Příliš krátké jméno', 'error');
} else {
$msg = 1;
}
if ($msg != 1) {
unset($formVal["pwd"], $formVal["pwd2"], $formVal["confirmation"]);
$this->presenter->redirect(":Front:Sign:up", $formVal);
}
}
示例3: setEmail
/**
* @param $email
* @throws \Nette\InvalidArgumentException
*/
public function setEmail($email)
{
if (!Validators::isEmail($email)) {
throw new InvalidArgumentException("Email must be in correct format.");
}
$this->email = $email;
}
示例4: setEmails
/**
* @param array $emails
* @return $this
* @throws Exception
* @throws \Dibi\Exception
*/
public function setEmails(array $emails)
{
$this->dbPostfix->begin();
try {
foreach ($emails as $email) {
if (!empty($email->id)) {
$this->dbPostfix->query("UPDATE mailbox SET [user]=%s, password=%s WHERE id=%i", $email->username, $email->password, $email->id);
} else {
$this->dbPostfix->query("INSERT INTO mailbox", array('user' => $email->username, 'password' => $email->password, 'domain_id' => $this->getDomainId()));
}
if (!empty($email->alias)) {
$aliases = explode(',', str_replace(' ', '', $email->alias));
foreach ($aliases as $alias) {
if (!\Nette\Utils\Validators::isEmail($alias)) {
throw new CmsException($alias . ' není platný email.');
}
}
$aliasId = $this->dbPostfix->query("SELECT id FROM alias WHERE domain_id=%i AND [user]=%s", $this->getDomainId(), $email->username)->fetchSingle();
if (!empty($aliasId)) {
$this->dbPostfix->query("UPDATE alias SET target=%s WHERE id=%i", implode(',', $aliases), $aliasId);
} else {
$this->dbPostfix->query("INSERT INTO alias", array('domain_id' => $this->getDomainId(), 'user' => $email->username, 'target' => implode(',', $aliases)));
}
}
}
} catch (Exception $ex) {
$this->dbPostfix->rollback();
throw $ex;
}
$this->dbPostfix->commit();
return $this;
}
示例5: __construct
/**
* @param $email
*/
public function __construct($email)
{
if (!Validators::isEmail($email)) {
throw new \InvalidArgumentException("{$email} is not email.");
}
$this->email = $email;
}
示例6: sendFormSucceeded
function sendFormSucceeded(\Nette\Forms\BootstrapUIForm $form)
{
$email = $form->getValues()->email;
if ($form->values->layer == 'admin') {
$lostPass = $this->database->table("helpdesk_emails")->where("template", "lostpass-admin")->fetch();
} else {
$lostPass = $this->database->table("helpdesk_emails")->where("template", "lostpass-member")->fetch();
}
if (!\Nette\Utils\Validators::isEmail($email)) {
$this->presenter->flashMessage("Adresa je neplatná");
$this->presenter->redirect(":Front:Sign:lostpass");
}
$passwordGenerate = \Nette\Utils\Random::generate(12, "987654321zyxwvutsrqponmlkjihgfedcba");
if ($this->database->table('users')->where(array('email' => $email))->count() == 0) {
$this->flashMessage("E-mail nenalezen");
$this->presenter->redirect(":Front:Sign:lostpass");
}
$member = new \App\Model\MemberModel($this->database);
$member->setActivation($email, $passwordGenerate);
$latte = new \Latte\Engine();
$latte->setLoader(new \Latte\Loaders\StringLoader());
$params = array('code' => $passwordGenerate, 'email' => $email, 'settings' => $this->presenter->template->settings);
$mail = new \Nette\Mail\Message();
$mail->setFrom($this->presenter->template->settings['contacts:email:hq'])->addTo($email)->setSubject("Informace o novém hesle")->setHTMLBody($latte->renderToString($lostPass->body, $params));
$mailer = new \Nette\Mail\SendmailMailer();
$mailer->send($mail);
$this->presenter->flashMessage('Informace o zapomenutém hesle odeslány', 'success');
$this->presenter->redirect(this);
}
示例7: validateEmail
private function validateEmail($email)
{
if (preg_match('#^(.+) +<(.*)>\\z#', $email, $matches)) {
$email = $matches[2];
} else {
$email = $email;
}
return \Nette\Utils\Validators::isEmail($email);
}
示例8: execute
/**
* @inheritdoc
*/
protected function execute(InputInterface $input, OutputInterface $output) : int
{
$email = $input->getArgument('email');
$password = $input->getArgument('password');
$role = $input->getArgument('role');
if (!Validators::isEmail($email)) {
$output->writeln("<error>First argument must be valid email, but '{$email}' given!</error>");
return 1;
}
$this->registrator->register($email, $password, $role);
return 0;
}
示例9: beforeCompile
public function beforeCompile()
{
$containerBuilder = $this->getContainerBuilder();
$mailerAlias = $containerBuilder->getByType('Nette\\Mail\\IMailer');
$mailerDefinition = $containerBuilder->getDefinition($mailerAlias);
$mailerFactory = $mailerDefinition->getFactory();
$mailerDefinition->setFactory('Simplement\\MailQueue\\Mailer', array($mailerFactory))->addSetup('setConfig', array($this->config));
if (!$this->config['defaultSender'] && isset($mailerFactory->arguments['smtp']) && $mailerFactory->arguments['smtp'] && isset($mailerFactory->arguments['username']) && ($email = $mailerFactory->arguments['username']) && \Nette\Utils\Validators::isEmail($this->getMail($email))) {
$this->config['defaultSender'] = $email;
}
$containerBuilder->getDefinition($this->prefix('command.sendfronted'))->addSetup('setConfig', array($this->config));
$containerBuilder->getDefinition($this->prefix('command.send'))->addSetup('setConfig', array($this->config));
}
示例10: __construct
public function __construct($email, $password)
{
$email = (string) $email;
$password = (string) $password;
if (!Validators::isEmail($email)) {
throw new EntityInvalidArgumentException(sprintf('Invalid e-mail %s.', $email));
}
if (strlen($password) < self::PASSWORD_MIN_LENGTH) {
throw new EntityInvalidArgumentException(sprintf('Password must be at least %d characters long.', self::PASSWORD_MIN_LENGTH));
}
$this->email = $email;
$this->password = Passwords::hash($password);
$this->carts = new ArrayCollection();
}
示例11: sendFormValidated
function sendFormValidated(\Nette\Forms\BootstrapUIForm $form)
{
if (strlen($form->values->name) < 2) {
$this->flashMessage($this->translator->translate('messages.sign.fillInName'), "error");
$this->redirect(":Front:Contact:default");
}
if (\Nette\Utils\Validators::isEmail($form->values->email) == FALSE) {
$this->flashMessage($this->translator->translate('messages.sign.fillInEmail'), "error");
$this->redirect(":Front:Contact:default");
}
if (strlen($form->values->message) < 2) {
$this->flashMessage($this->translator->translate('messages.sign.fillInMessage'), "error");
$this->redirect(":Front:Contact:default");
}
}
示例12: signFormValidated
function signFormValidated(\Nette\Forms\BootstrapPHForm $form)
{
$event = $this->database->table("events")->get($form->values->event);
if (strlen($form->values->name) < 2) {
$this->presenter->flashMessage('Vyplňte jméno', "error");
$this->presenter->redirect(this, array("id" => $event->pages_id, "event" => $event->id));
}
if (\Nette\Utils\Validators::isEmail($form->values->email) == FALSE) {
$this->presenter->flashMessage('Vyplňte e-mail', "error");
$this->presenter->redirect(this, array("id" => $event->pages_id, "event" => $event->id));
}
$eventSigned = $this->database->table("events_signed")->where(array("email" => $form->values->email, "events_id" => $event->id));
if ($eventSigned->count() > 0) {
$this->presenter->flashMessage('Tento e-mail už byl použit při registraci', "error");
$this->presenter->redirect(this, array("id" => $event->pages_id, "event" => $event->id));
}
}
示例13: elseif
} elseif ($field->getName() === 'companies') {
unset($values['id']);
$context->table('companies')->where('id = ?', $reference->getToValue())->update($values);
} elseif ($field->getName() === 'group') {
unset($values['id']);
$context->table('groups')->where('id = ?', $reference->getToValue())->update($values);
} elseif ($field->getName() === 'wallet') {
unset($values['id'], $values['wallet_id']);
$context->table('wallets')->where('id = ?', $reference->getToValue())->update($values);
}
};
$editable->onEditField[] = function (\Mesour\Editable\Structures\Fields\IStructureField $field, $newValue, $oldValue, $identifier = null, array $params = []) use($context, $source) {
if ($field->getName() === 'group') {
$data = ['group_id' => !$newValue ? null : $newValue];
} else {
if ($field->getName() === 'email' && !\Nette\Utils\Validators::isEmail($newValue)) {
$exception = new \Mesour\Editable\ValidatorException('Value must be valid email.');
$exception->setFieldName($field->getName());
throw $exception;
}
$data = [$field->getName() => $newValue === false ? 0 : $newValue];
}
$context->table('users')->where('id = ?', $identifier)->update($data);
};
$created = $editable->create();
$currentUser = $source->fetch();
$currentUserId = $currentUser['id'];
?>
<hr style="margin-bottom: 50px;">
示例14: validateEmail
/**
* @param string
* @throws \Nette\InvalidArgumentException
*/
private function validateEmail($email)
{
if (!\Nette\Utils\Validators::isEmail($email)) {
throw new \Nette\InvalidArgumentException();
}
}
示例15: setEmail
/**
* @param string $email
*/
public function setEmail($email)
{
if (!\Nette\Utils\Validators::isEmail($email)) {
throw new \Nette\InvalidArgumentException(sprintf('E-mail must be in correct format. \'%s\' is given.', $email));
}
$this->email = $email;
}