/**
  * @param array $params
  * @throws InvalidServerConfigException
  */
 private static function validate(array $params)
 {
     $validator = new ArrayValidator(self::$validParams, self::$validParams);
     if (!$validator->validate($params)) {
         throw new InvalidServerConfigException();
     }
 }
Exemplo n.º 2
0
 public function testCustomExceptionCallbackOnNonCleanException()
 {
     $validator = $this->prophesize('hanneskod\\clean\\Validator');
     $validator->validate('foo')->willThrow(new \Exception());
     $validator = new ArrayValidator(['foo' => $validator->reveal()]);
     $called = false;
     $validator->onException(function (\Exception $exception) use(&$called) {
         $called = true;
     });
     $validator->validate(['foo' => 'foo']);
     $this->assertTrue($called, 'The exception should be caught even though it is a base exception');
 }
 function validate()
 {
     // fetch the validated data
     $this->_postLinks = $this->_request->getValue("postLink");
     $this->_trackbackLinks = $this->_request->getValue("trackbackLink");
     $this->_postId = $this->_request->getValue("postId");
     $intval = new IntegerValidator();
     if (!$intval->validate($this->_postId)) {
         $this->_view = new AdminPostsListView($this->_blogInfo);
         $this->_view->setErrorMessage($this->_locale->tr("error_incorrect_article_id"));
         $this->setCommonData();
         return false;
     }
     $arrryval = new ArrayValidator();
     if (!$arrryval->validate($this->_postLinks) && !$arrryval->validate($this->_trackbackLinks)) {
         $this->_view = new AdminPostsListView($this->_blogInfo);
         $this->_view->setErrorMessage($this->_locale->tr("error_no_trackback_links_sent"));
         $this->setCommonData();
         return false;
     }
     return true;
 }
Exemplo n.º 4
0
 public function __construct($allowNull = true, $elementValidator = null)
 {
     parent::__construct($allowNull, new ArrayValidator($allowNull, $elementValidator));
 }