How to validate data for a Rest Service with symfony

Posted by Nicolas V. on Stack Overflow See other posts from Stack Overflow or by Nicolas V.
Published on 2010-08-02T09:46:17Z Indexed on 2010/12/23 14:54 UTC
Read the original article Hit count: 215

Filed under:
|
|
|

For example imagine I've a rest service, this service takes two parameters :

  • phone number
  • text

The goal is to send the message via a sms gateway.

I've a class Message which has two properties destinationNumber and textMessage. Before calling the gateway, I want to validate the data received by the rest service.

I've two questions relatives to how to validate the data :

  • Where should I put the validation rules ? in the model or in the controller
  • How should I use the sfValidator* classes from Symfony to validate the data (ie. where's the documentation for using sfValidator or where can I find some examples)

Any help would be appreciated.

© Stack Overflow or respective owner

Related posts about mvc

Related posts about validation