Created
June 1, 2017 15:31
-
-
Save geggleto/57550e105afb83fa4d8ecd8b2817e7e2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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