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(),
)
);
精彩评论