Dimmduh
Dimmduh

Reputation: 843

Zend Framework: how to use validator in router.xml

I've created the validator SportNameValidator and I want to use it to check variables in the url. How can I put a validator to routes.xml?

This is the part of file:

<rss_top_news_by_sportname>
<type>Zend_Controller_Router_Route_Regex</type>
<route>export/rss/top/news/([a-z]+).xml</route>
<defaults>
    <controller>export</controller>
    <action>rssTopNewsBySportName</action>
</defaults>
<map>
    <sportname>1</sportname>
</map>

Upvotes: 0

Views: 137

Answers (1)

S3Mi
S3Mi

Reputation: 488

Validators are used to validate user input in forms, not routes. But you can use this validaton mechanism in controller to validate url.

$validator = new SportNameValidator();
$valid = $validator->isValid($url_or_part_of_url_you_want_to_validate);

Upvotes: 3

Related Questions