postgres dyanmic and unlimited where conditions
Have the function take a structure that defines the constraint to apply and parse that structure into a SQL where expression, then execute it.

The structure could be represented as JSON, XML, or any other type that can be handled by postgresql built-ins or your code.

For safety aghainst injection attacks be sure to not copy any raw data from the struct to the query, all values and identifiers should be quoted (quote_identifier(), quote_nullable(), etc...) and all operators should come from string literals in the function code.

the function itself would be structured like something like.

CREATE OR REPLACE FUNCTION filter( conditions text ) 
   RETURNS SETOF sometable 
   LANGUAGE plpgsql 
   AS $$
        DECLARE 
          whereclause text := '';
        BEGIN
          whereclause = whereclause || conditions 
          RETURN QUERY EXECUTE 
             'SELECT * FROM sometable WHERE ' || whereclause;
        END;
      $$;


but probably with some more involved processing of conditions before the RETURN QUERY EXECUTE