if not database_exists(astring):
    raise ValueError
return astring
parser.add_argument('--database', dest='database', type=database, default=
    None, required=False, help='Database to restore')
Python: Argument Parsing Validation Best Practices