本文整理匯總了PHP中Respect\Validation\Validator::email方法的典型用法代碼示例。如果您正苦於以下問題:PHP Validator::email方法的具體用法?PHP Validator::email怎麽用?PHP Validator::email使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Respect\Validation\Validator
的用法示例。
在下文中一共展示了Validator::email方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: checkPasswordCredential
/**
* 檢查密碼是否正確
*
* @param string $field
* @param string $password
* @param bool $secretly
* @return array
* @throws UserException
*/
public function checkPasswordCredential($field, $password, $secretly = false)
{
if (Validator::email()->validate($field)) {
$user = UserUtil::getUserObjectByEmail($field);
} else {
$user = UserUtil::getUserObjectByUsername($field);
}
if (!UserUtil::isUserObjectValid($user)) {
if (!$secretly) {
Application::emit('user.login.failed.user_invalid', [VJ::LOGIN_TYPE_FAILED_USER_INVALID, $field]);
Application::info('credential.login.not_found', ['login' => $field]);
}
throw new UserException('UserCredential.checkPasswordCredential.user_not_valid');
}
$verified = $this->password_encoder->verify($password, $user['salt'], $user['hash']);
if (!$verified) {
if (!$secretly) {
Application::emit('user.login.failed.wrong_password', [VJ::LOGIN_TYPE_FAILED_WRONG_PASSWORD, $user]);
Application::info('credential.login.wrong_password', ['uid' => $user['uid']]);
}
throw new UserException('UserCredential.checkPasswordCredential.wrong_password');
}
if (!$secretly) {
Application::emit('user.login.succeeded', [VJ::LOGIN_TYPE_INTERACTIVE, $user, $field, $password]);
Application::info('credential.login.ok', ['uid' => $user['uid']]);
}
return $user;
}
示例2: validate
public function validate($data)
{
$validator = V::key('name', V::string()->length(0, 100), true)->key('email', V::email()->length(0, 200), true)->key('password', V::string()->length(0, 100), true);
try {
$validator->assert($data);
switch ($data['userable_type']) {
case 'Designer':
$this->designerCreationValidator->validate($data);
$data['userable_type'] = DesignerModel::class;
break;
case 'Administrator':
$this->adminCreationValidator->validate($data);
$data['userable_type'] = AdministratorModel::class;
break;
case 'Buyer':
$this->buyerCreationValidator->validate($data);
$data['userable_type'] = BuyerModel::class;
break;
default:
break;
}
} catch (AbstractNestedException $e) {
$errors = $e->findMessages(['email', 'length', 'in']);
throw new ValidationException('Could not create user.', $errors);
}
return true;
}
示例3: initRule
/**
* init valid rule
*/
protected function initRule()
{
$this->validRule['id'] = v::numeric();
$this->validRule['name'] = v::stringType()->length(1, 10);
$this->validRule['email'] = v::email();
$this->validRule['sex'] = v::intVal()->between(0, 1);
}
示例4: isValid
public function isValid($validation_data)
{
$errors = [];
foreach ($validation_data as $name => $value) {
if (isset($_REQUEST[$name])) {
$rules = explode("|", $value);
foreach ($rules as $rule) {
$exploded = explode(":", $rule);
switch ($exploded[0]) {
case 'min':
$min = $exploded[1];
if (Valid::stringType()->length($min)->Validate($_REQUEST[$name]) == false) {
$errors[] = $name . " must be at least " . $min . " characters long";
}
break;
case 'email':
if (Valid::email()->Validate($_REQUEST[$name]) == false) {
$errors[] = $name . " must be a valid email ";
}
break;
case 'equalTo':
if (Valid::equals($_REQUEST[$name])->Validate($_REQUEST[$exploded[1]]) == false) {
$errors[] = "Values do not match";
}
break;
default:
//do nothing
}
}
} else {
$errors = "No value found";
}
}
return $errors;
}
示例5: validatePasswordResetRequest
public function validatePasswordResetRequest($email, $token)
{
Auth::restrictAccess('anonymous');
$passwordResets = new PasswordResets();
// This needs to go into base functions and return some kind of json message
if (!v::email()->validate($email)) {
return 'email dont comply';
}
if (!v::xdigit()->length(32, 32)->validate($token)) {
return 'token dont comply';
}
$passwordReset = $passwordResets->show($email);
// Not going to reveal whether the user account was found...
if (empty($passwordReset['token']) || empty($passwordReset['created'])) {
echo 'password reset request not found. forward. please submit a password reset request first';
die;
}
$created = strtotime($passwordReset['created']);
$now = strtotime(date('Y-m-d H:i:s'));
$diff = round(($now - $created) / 60, 2);
if (intval($diff) > 60) {
echo 'password reset has expired. 60 minutes max. submit another reset request';
die;
}
if (password_verify($token, $passwordReset['token'])) {
// probably shouldnt disclose this. just send json success
echo 'password matches. proceed to reset.';
}
return $passwordReset;
}
示例6: email
/**
* @param $param
* @return string
* @throws EntityValidationException
*/
public function email($param)
{
if (!v::email()->validate($param)) {
throw new EntityValidationException('User', 'email', $param, 'Invalid email');
}
return $param;
}
示例7: validate
public function validate($prop, $label)
{
$value = $this->getValue($prop);
if (!v::email()->validate($value)) {
$this->addException("O campo {$label} não contém um e-mail válido");
}
}
示例8: setAlternativeEmail
public function setAlternativeEmail($value)
{
if (!v::email()->validate($value)) {
throw new FieldRequiredException("E-mail alternativo inválido");
}
$this->_email .= "," . $value;
}
示例9: isValid
public function isValid($validation_data)
{
$errors = [];
foreach ($validation_data as $name => $value) {
$exploded = explode(":", $value);
switch ($exploded[0]) {
case 'min':
$min = $exploded[1];
if (Valid::stringType()->length($min, null)->Validate($_REQUEST[$name]) == false) {
$errors[] = $exploded[2] . " must be at least " . $min . " characters long ";
}
break;
case 'email':
if (Valid::email()->Validate($_REQUEST[$name]) == false) {
$errors[] = "Please enter a valid email";
}
break;
case 'equalTo':
if (Valid::equals($_REQUEST[$name])->Validate($_REQUEST[$exploded[1]]) == false) {
$errors[] = $exploded[2] . " value does not match " . $exploded[3] . " value";
}
break;
default:
//do nothing
$errors[] = "No values found";
}
}
return $errors;
}
示例10: isValid
public function isValid($validation_data)
{
$errors = [];
foreach ($validation_data as $name => $value) {
$rules = explode("|", $value);
foreach ($rules as $rule) {
$exploded = explode(":", $rule);
switch ($exploded[0]) {
case 'min':
$min = $exploded[1];
if (Valid::stringType()->length($min, null)->Validate($_REQUEST[$name]) == false) {
$errors[] = $name . " must be at least " . $min . " characters long!";
}
break;
case 'email':
if (Valid::email()->Validate($_REQUEST[$name]) == false) {
$errors[] = $name . " must be a valid email address!";
}
break;
case 'equalTo':
if (Valid::equals($_REQUEST[$name])->Validate($_REQUEST[$exploded[1]]) == false) {
$errors[] = "Value does not match verification value!";
}
break;
default:
$errors[] = "No value found!";
}
}
}
return $errors;
}
示例11: isValid
public function isValid($validation_data)
{
$errors = "";
foreach ($validation_data as $name => $value) {
$rules = explode("|", $value);
foreach ($rules as $rule) {
$exploded = explode(":", $rule);
switch ($exploded[0]) {
case 'min':
$min = $exploded[1];
if (Valid::alpha()->length($min)->Validate($_POST[$name]) == false) {
$errors[] = $name . " must be at least " . $exploded[1] . " characters long!";
}
break;
case 'email':
if (Valid::email()->validate($_POST[$name]) == false) {
$errors[] = $name . " must be a valid email address!";
}
break;
case 'equalTo':
if (Valid::equals($_POST[$name])->validate($_POST[$exploded[1]]) == false) {
$errors[] = $name . "'s don't match!";
}
break;
default:
$errors[] = "No value found!";
break;
}
}
}
return $errors;
}
示例12: send
private function send($type, array $to, $subject, $template, $params)
{
if (!Validator::arr()->each(Validator::email())->validate($to)) {
throw new InvalidArgumentException('to', 'format_invalid');
}
$html = Application::get('templating')->render($template, array_merge(['SUBJECT' => $subject], $params));
$this->provider->send($type, $to, $subject, $html);
}
示例13: setData
public function setData($data)
{
if (!is_string($data) || !v::email()->validate($data)) {
throw new \RuntimeException('EmailField data must be a valid representation of an email address ');
}
$this->data = $data;
return $this;
}
示例14: validateEmail
protected function validateEmail()
{
$value = v::email()->notEmpty()->validate($this->getEmail());
if (!$value) {
msg::showMsg('O campo E-mail deve ser preenchido corretamente.' . '<script>focusOn("email");</script>', 'danger');
}
$this->criptoVar('email', $this->getEmail());
return $this;
}
示例15: create
/**
* Creates a profile.
*
* @param string $uniqueness
* @param string $email
*
* @throws InvalidEmailException
*
* @return string
*/
public function create($uniqueness, $email)
{
if (!Validator::email()->validate($email)) {
throw new InvalidEmailException();
}
$uniqueness = $uniqueness ?: uniqid();
$this->connectToStorage->connect()->insertOne(new Profile($uniqueness, $email));
return $uniqueness;
}