Neos\Flow\Mvc\Controller\Argument::setValidator PHP Method

setValidator() public method

Sets a custom validator which is used supplementary to the base validation
public setValidator ( Neos\Flow\Validation\Validator\ValidatorInterface $validator ) : Argument
$validator Neos\Flow\Validation\Validator\ValidatorInterface The actual validator object
return Argument Returns $this (used for fluent interface)
    public function setValidator(ValidatorInterface $validator)
    {
        $this->validator = $validator;
        return $this;
    }

Usage Example

Esempio n. 1
0
 /**
  * @test
  */
 public function setValueShouldSetValidationErrorsIfValidatorIsSetAndValidationFailed()
 {
     $error = new FLowError\Error('Some Error', 1234);
     $mockValidator = $this->createMock(ValidatorInterface::class);
     $validationMessages = new FLowError\Result();
     $validationMessages->addError($error);
     $mockValidator->expects($this->once())->method('validate')->with('convertedValue')->will($this->returnValue($validationMessages));
     $this->simpleValueArgument->setValidator($mockValidator);
     $this->setupPropertyMapperAndSetValue();
     $this->assertEquals([$error], $this->simpleValueArgument->getValidationResults()->getErrors());
 }