Skip to content

Instantly share code, notes, and snippets.

@pschichtel
Created June 15, 2012 07:24
Show Gist options
  • Save pschichtel/2935194 to your computer and use it in GitHub Desktop.
Save pschichtel/2935194 to your computer and use it in GitHub Desktop.
<?php
class TestController implements Controller
{
/**
* @validate id numeric
* @validate message maxlen(300)
* @method post
* @ajax false
*/
public function messageAction($id, $message)
{
// will only be called when both $id and $message are available and have passed the validation
}
}
interface Validator
{
public function validate($value, array $args);
}
public NumericValidator implements Validator
{
public function validate($value, array $args)
{
return is_numeric($value);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment