5

In the documentation is said that we can apply a complex constraint on a query param like:

@QueryParam(
    array=true, 
    name="filters", 
    requirements=@MyComplexConstraint, 
    description="List of complex filters"
)

taken from https://github.com/FriendsOfSymfony/FOSRestBundle/blob/master/Resources/doc/3-listener-support.md

But when I try to use it in my project:

@Annotations\QueryParam(
    name="departurePoint", 
    array=true, 
    strict=true, 
    requirements=@DeparturePoint,
    nullable=false, 
    description="The destination from where to start the journey"
)

with the proper use of DeparturePoint, which is implemented as a symfony constraint, it throws an error saying that requirements parameter can only be a string.

Is it possible to use a custom validator for a queryParam?

qooplmao
  • 17,622
  • 2
  • 44
  • 69
Stev
  • 1,062
  • 11
  • 23
  • I just needed to update the bundle to the latest version as sf2 rest edition comes bundled with an older one. – Stev Jul 15 '14 at 08:55

0 Answers0