validate generic_controller in di extension and reformat code

| Q             | A
| ------------- | ---
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #153
| License       | MIT

this is a cleanup of 788a55b0e41dc16abfc12bf64d2885b0fa55ca70 to add minimal validation