I use this function to make sure only things with "Coin" in their name can go into a specific bag.

function filterObjectEnter(obj)
    local name = obj.getName()

    if type(name) != 'string' then return false end

    return name:find('Coin') != nil
If I multi-select a Coin and something that is not a Coin, and then I drag the Coin into the purse, both objects enter the bag.