While you're at it, you could also add some checks for other common
white space errors. The sample pre-commit hook that comes with each
repository have this check enabled, you just have to enable that hook by
renaming it from pre-commit.sample to just pre-commit. Then you have to
adjust the git config core.whitespace to whatever you want to check
(there are several options, see git config --help for details).
Unfortunately those checks don't include either the CRLF check or the
"all spaces" (there is an option to check the opposite, that only tab is
used for indentation), but it cover other common errors as trailing
white spaces.
If there's going to be advanced validation, maybe it's better to create a formatting tool similar to gofmt. If passing a source file through it alters the file, it fails. The tool can be shared and could help establish a standard format for D code (or at least Phobos code).
I've never used gofmt, but did find the following link online: