开发者

Is it possible to define more than one post-validator in Symfony?

I need to perform several post-validations in a Symfony form. First time I came across this issue I wrote this:

$this->validatorSchema->setPostValidator(
  new sfValidatorCallback(array(
    'callback' => array($this, 'checkStatusHasMethod'))
));

since I only wanted to check a certain situation.

But as the application has grown, I need now to perform additional checks. I would like to keep every validation isolated in different methods, instead of having a big开发者_运维技巧 checkX method where everything is kept together.

Is it possible to associate a sfPostValidator with more than one method or create several sfPostValidator instances in validatorSchema?

Thanks!


Try mergePostValidator() (or similar, can't remember the exact method name)


As far as I remember, there's a validator called sfValidatorAnd() that allows you to do that.

Edit : you can do that :

new sfValidatorAnd(
    array(
        new sfValidatorString(),
        new sfValidatorRegex(),
    )
);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜