Verify a Minesweeper board Your goal is to check whether a completed Minesweeper board is valid. This means that each number is a correct count of mines in cells adjacent to it, including diagonals. The board does not wrap around.

As usual, you should give a function or program, and shortest code in bytes wins.

See also past challenges to generate, solve, and fully implement Minesweeper.

Input:

A single string like this: 02X2 13X2 X211. 


The rows of the minesweeper board are given separated by spaces. So, the above represents the 3x4 board:

02X2
13X2
X211 
Each cell is a character: X for a mine, or a number 0 through 8.
All rows have the same length.  
There are at least 3 rows and 3 columns.
The input doesn't start or end with a space, but you may include a newline at the end if you wish.


Output:

A consistent Truthy on correct boards, and a consistent Falsey value on incorrect boards. Consistent means that all Truthy outputs are the same and all Falsey outputs are the same.

Test cases

Each line is a separate test case.

True:

02X2 13X2 X211
XXXX XXXX XXXX XXXX
XX4X2 5X6X4 XX6XX 4XX54 2X4XX


False:

02X2 13X2 X212
XXXX XXXX X7XX XXXX
XX5X2 5X6X4 XX6XX 4XX54 2X5XX
Python 2, 132 129 128
def f(s):w=s.find(' ');E=dict(enumerate(s));return all(E[i]in' X'+`sum(E.get(i+d/3*~w+d%3+w,5)&gt;'O'for d in range(9))`for i in E)

I used enumerate in a golf...and even used range elsewhere in the same program. Clearly something is wrong here.
Edit: Iterate over dict(enumerate(s)) rather than enumerate(s), so enumerate does not need to be called twice.