def _validate_integer(name, val, min_val=<NUM_LIT:0>):
msg = "<STR_LIT>".format(name=name,<EOL>min_val=min_val)<EOL>if val is not None:<EOL><INDENT>if is_float(val):<EOL><INDENT>if int(val) != val:<EOL><INDENT>raise ValueError(msg)<EOL><DEDENT>val = int(val)<EOL><DEDENT>elif not (is_integer(val) and val >= min_val):<EOL><INDENT>raise ValueError(msg)<EOL><DEDENT><DEDENT>return val<EOL>
Checks whether the 'name' parameter for parsing is either
an integer OR float that can SAFELY be cast to an integer
without losing accuracy. Raises a ValueError if that is
not the case.

Parameters
----------
name : string
    Parameter name (used for error reporting)
val : int or float
    The value to check
min_val : int
    Minimum allowed value (val < min_val will result in a ValueError)