def check(table='filter', chain=None, rule=None, family='ipv4'):
    if not chain:
        return 'Error: Chain needs to be specified'
    if not rule:
        return 'Error: Rule needs to be specified'

    if not check_table(table, family=family):
        return 'Error: table {0} in family {1} does not exist'.\
                format(table, family)

    if not check_chain(table, chain, family=family):
        return 'Error: chain {0} in table {1} in family {2} does not exist'.\
                format(chain, table, family)

    nft_family = _NFTABLES_FAMILIES[family]
    cmd = '{0} --handle --numeric --numeric --numeric list chain {1} {2} {3}'.\
            format(_nftables_cmd(), nft_family, table, chain)
    search_rule = '{0} #'.format(rule)
    out = __salt__['cmd.run'](cmd, python_shell=False).find(search_rule)

    if out != -1:
        out = ''
    else:
        return False

    if not out:
        return True
    return out
Check for the existence of a rule in the table and chain
dataset/ETHPy150Open saltstack/salt/salt/modules/nftables.py/check