def parseOptions(userOptions, jobOptions):
    """
    Verifies that user supplied options fit the criteria for a set of
    job options

    Args:
        userOptions: a set of user supplied options
        jobOptions: an option schema for a job
    Returns:
        a list of errors (can be empty)
        options to send to the job server
    """

    sendOptions = {}
    errors = []

    for name, info in jobOptions.items():

        # grab info about the option
        optionType = info["TYPE"]
        required = info["REQUIRED"]
        default = info.get("DEFAULT",None)

        # retrieve the user value for an option
        value = userOptions.get(name,None)

        # handle default/required case
        if value is None:
            if default is not None:
                value = default
            else:
                if required:
                    errors.append("The option '%s' is required" % name)
                continue

        # coerce the type of an option
        if optionType == "string":
            value = str(value)
        elif optionType == "int":
            value = int(value)
        elif optionType == "float":
            value = float(value)

        sendOptions[name] = value

    return errors, sendOptions