Validate args

def validate(args):
    """
    Validate args
    """
    provided = {key: val for key, val in args.iteritems() if val is not None}
    schema = Schema({
        '--user': And(str, len, Use(str.lower)),
        '--server': And(str, len, Use(str.lower)),
        '--cacert': os.path.isfile,
        # ops
        Optional('create'): Use(bool),
        Optional('delegate'): Use(bool),
        Optional('encrypt'): Use(bool),
        Optional('decrypt'): Use(bool),
        Optional('summary'): Use(bool),
        Optional('change-password'): Use(bool),
        Optional('modify'): Use(bool),
        Optional('base64-encode'): Use(bool),
        # delegate params
        Optional('--time'): And(str, len),
        Optional('--uses'): Use(int),
        # encrypt/decrypt params
        Optional('--owners'): And(str, len, Use(str.lower)),
        Optional('--min'): Use(int),
        Optional('--str'): And(str, len),
        Optional('--file'): os.path.isfile,
        # modify params
        Optional('--action'): And(str, len, Use(str.lower)),
        Optional('--target'): And(str, len, Use(str.lower)),
    })
    try:
        return merge(schema.validate(provided), args)
    except SchemaError as ex:
        abort("Missing, invalid or unexpected argument.\n{}".format(ex.message))