/** * Checks if the given value is a valid electronic address according to its type. * * If at least one error occurred, the result is FALSE and any errors can * be retrieved through the getErrors() method. * * @param mixed $value The value that should be validated * @return void */ public function isValid($value) { if ($value instanceof \TYPO3\Party\Domain\Model\ElectronicAddress) { if ($this->isValidatedAlready($value)) { return; } $addressValidator = $this->validatorResolver->createValidator($value->getType() . 'Address'); if ($addressValidator === NULL) { $this->addError('No validator found for electronic address of type "' . $value->getType() . '".', 1268676030); } else { $result = $addressValidator->validate($value->getIdentifier()); if ($result->hasErrors()) { $this->result = $result; } } } }
/** * Checks for a collection and if needed validates the items in the collection. * This is done with the specified element validator or a validator based on * the given element type and validation group. * * Either elementValidator or elementType must be given, otherwise validation * will be skipped. * * @param mixed $value A collection to be validated * @return void */ protected function isValid($value) { foreach ($value as $index => $collectionElement) { if (isset($this->options['elementValidator'])) { $collectionElementValidator = $this->validatorResolver->createValidator($this->options['elementValidator']); } elseif (isset($this->options['elementType'])) { if (isset($this->options['validationGroups'])) { $collectionElementValidator = $this->validatorResolver->getBaseValidatorConjunction($this->options['elementType'], $this->options['validationGroups']); } else { $collectionElementValidator = $this->validatorResolver->getBaseValidatorConjunction($this->options['elementType']); } } else { return; } if ($collectionElementValidator instanceof ObjectValidatorInterface) { $collectionElementValidator->setValidatedInstancesContainer($this->validatedInstancesContainer); } $this->result->forProperty($index)->merge($collectionElementValidator->validate($collectionElement)); } }
/** * Checks if the given value is a valid electronic address according to its type. * * If at least one error occurred, the result is FALSE and any errors can * be retrieved through the getErrors() method. * * @param mixed $value The value that should be validated * @return void */ public function isValid($value) { if ($value instanceof \TYPO3\Party\Domain\Model\ElectronicAddress) { $addressType = $value->getType(); switch ($addressType) { case 'Email': $addressValidator = $this->validatorResolver->createValidator('EmailAddress'); break; default: $addressValidator = $this->validatorResolver->createValidator('TYPO3.Party:' . $addressType . 'Address'); } if ($addressValidator === NULL) { $this->addError('No validator found for electronic address of type "' . $addressType . '".', 1268676030); } else { $result = $addressValidator->validate($value->getIdentifier()); if ($result->hasErrors()) { $this->result = $result; } } } }
public function initializeMergeAction() { if (!$this->request->hasArgument('try')) { return; } $validators = $this->arguments->getArgument('tryagain')->getValidator(); $notempty = $this->validatorResolver->createValidator('NotEmpty'); $validators->addValidator($notempty); }