public function SocialUserNameConstraintValidator::validate in Open Social 8.4
Same name and namespace in other branches
- 8.9 modules/social_features/social_user/src/Plugin/Validation/Constraint/SocialUserNameConstraintValidator.php \Drupal\social_user\Plugin\Validation\Constraint\SocialUserNameConstraintValidator::validate()
- 8 modules/social_features/social_user/src/Plugin/Validation/Constraint/SocialUserNameConstraintValidator.php \Drupal\social_user\Plugin\Validation\Constraint\SocialUserNameConstraintValidator::validate()
- 8.2 modules/social_features/social_user/src/Plugin/Validation/Constraint/SocialUserNameConstraintValidator.php \Drupal\social_user\Plugin\Validation\Constraint\SocialUserNameConstraintValidator::validate()
- 8.3 modules/social_features/social_user/src/Plugin/Validation/Constraint/SocialUserNameConstraintValidator.php \Drupal\social_user\Plugin\Validation\Constraint\SocialUserNameConstraintValidator::validate()
- 8.5 modules/social_features/social_user/src/Plugin/Validation/Constraint/SocialUserNameConstraintValidator.php \Drupal\social_user\Plugin\Validation\Constraint\SocialUserNameConstraintValidator::validate()
- 8.6 modules/social_features/social_user/src/Plugin/Validation/Constraint/SocialUserNameConstraintValidator.php \Drupal\social_user\Plugin\Validation\Constraint\SocialUserNameConstraintValidator::validate()
- 8.7 modules/social_features/social_user/src/Plugin/Validation/Constraint/SocialUserNameConstraintValidator.php \Drupal\social_user\Plugin\Validation\Constraint\SocialUserNameConstraintValidator::validate()
- 8.8 modules/social_features/social_user/src/Plugin/Validation/Constraint/SocialUserNameConstraintValidator.php \Drupal\social_user\Plugin\Validation\Constraint\SocialUserNameConstraintValidator::validate()
- 10.3.x modules/social_features/social_user/src/Plugin/Validation/Constraint/SocialUserNameConstraintValidator.php \Drupal\social_user\Plugin\Validation\Constraint\SocialUserNameConstraintValidator::validate()
- 10.0.x modules/social_features/social_user/src/Plugin/Validation/Constraint/SocialUserNameConstraintValidator.php \Drupal\social_user\Plugin\Validation\Constraint\SocialUserNameConstraintValidator::validate()
- 10.1.x modules/social_features/social_user/src/Plugin/Validation/Constraint/SocialUserNameConstraintValidator.php \Drupal\social_user\Plugin\Validation\Constraint\SocialUserNameConstraintValidator::validate()
- 10.2.x modules/social_features/social_user/src/Plugin/Validation/Constraint/SocialUserNameConstraintValidator.php \Drupal\social_user\Plugin\Validation\Constraint\SocialUserNameConstraintValidator::validate()
File
- modules/
social_features/ social_user/ src/ Plugin/ Validation/ Constraint/ SocialUserNameConstraintValidator.php, line 38
Class
- SocialUserNameConstraintValidator
- Validates the UserName constraint no email address allowed in the username.
Namespace
Drupal\social_user\Plugin\Validation\ConstraintCode
public function validate($items, Constraint $constraint) {
if (is_null($items)) {
return;
}
if ($nameField = $items
->first()) {
$name = $nameField
->__get('value');
$definition = DataDefinition::create('string')
->setConstraints([
'Email' => [],
]);
$typed_data = $this->typedDataManager
->create($definition, $name);
$violations = $typed_data
->validate();
if (count($violations) == 0) {
$this->context
->addViolation($constraint->usernameIsEmailMessage);
}
}
}