Skip to content

Instantly share code, notes, and snippets.

@geggleto
Created June 1, 2017 15:31
Show Gist options
  • Save geggleto/57550e105afb83fa4d8ecd8b2817e7e2 to your computer and use it in GitHub Desktop.
Save geggleto/57550e105afb83fa4d8ecd8b2817e7e2 to your computer and use it in GitHub Desktop.
class UserRequestValidator
{
public function __invoke(Request $request, Response $response $next)
{
$validator = new Validator();
//rules
if ($validator->validate()) {
return $next(UserRequest::make($request));
// ^^ makes UserRequest subclass of Request
// or does it inject a UserDTO into a "attribute"
// Attributes are hard to document. Typed request class would be better in theory.
} else {
return $response;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment