from datetime import datetime


def datetime_string(format):
    """
    Return a value check function which raises a ValueError if the supplied
    value cannot be converted to a datetime using the supplied format string.

    See also `datetime.strptime`.

    """

    def checker(v):
        datetime.strptime(v, format)
    return checker