from typing import Union


def _get_file_name(arg: Union[str, None]) -> str:
    """
    Gets the option file name, validating the file extension. Returns "options.json" if no argument specified.

    :param arg: optional argument string
    :return:
    """
    name = 'options.json'
    if arg:
        name = arg
        if not name.endswith('.json'):
            raise ValueError('Only <name>.json files are allowed and the file must define a valid JSON!'
                             'You can generate one with the -g option.')
    return name