Reputation: 139
I try to validate a route in zend framework 2.
Example:
I tried this code, but I received 404 error:
'overview' => array(
'type' => 'segment',
'options' => array(
'route' => '/foo/overview/:nr',
'constraints' => array('nr' => '^[0-9]{1,4}-[0-9]{4}$',),
'defaults' => array(
'controller' => 'Foo\Controller\Foo',
'action' => 'overview',
),
),
),
thanks
Upvotes: 0
Views: 363
Reputation: 9008
It is enough to use [0-9]{1,4}-[0-9]{4}
for your constraint value, since the starting ^
and the closing $
are automatically added by the framework (check the match
function in the Zend\Mvc\Router\Http\Segment
class).
Upvotes: 2