Q:

Check Input Parameter And Raise Exception

Lately I've been working with some functions that apperently are working. 
I'd like to add some features, for example: "if the function input parameter is a string, it raises an exception, saying something". How can I do that?
 /*
 PLpgSQL function which behaves to aggregate the MIN(col)
 */
CREATE OR REPLACE FUNCTION searchMinimumValue (real,real) RETURNS real AS $$
DECLARE 
BEGIN
 IF $1 IS NULL OR $1 >= $2 THEN
    RETURN $2;
 ELSE
    RETURN $1;
 END IF;
 END;
 $$ LANGUAGE plpgsql;

 /*
Function which given the minimum value returned from the previous function,
adds the Laplacian noise.
Our upper bound is computed by doubling the epsilon value and then adding our minimum value found by the previous function.
The returned value from the function below will be the Laplace distribution value added to the output from the previous function.
 */
CREATE OR REPLACE FUNCTION addLaplacianNoiseMinimum(real) RETURNS real AS $$
DECLARE
  epsilon real := 1.2;
  sensivity real := (epsilon * 2) + $1;
  laplaceDistribution real;
BEGIN
  laplaceDistribution := sensivity / (epsilon);
  RETURN  $1 + laplaceDistribution;
END;
$$ LANGUAGE plpgsql;

CREATE AGGREGATE minimumLaplaceValue (real)
(
  sfunc = searchMinimumValue,
  stype = real,
  finalfunc = addLaplacianNoiseMinimum
); 

As I said before, I'd like to type something like this:
IF $1 IS NOT A NUMBER THEN RAISE EXCEPTION 'WRONG TYPE INPUT PARAMETER'

A:

I think so you cannot do this with Postgres - or you cannot to this without some unwanted side effects.
Postgres is strict type system - so all work with types should be done by Postgres.
But you can overload functions for some set of types of parameters:
CREATE OR REPLACE FUNCTION public.f1(numeric)
 RETURNS numeric
 LANGUAGE plpgsql
AS $function$
begin
  return $1;
end;
$function$

CREATE OR REPLACE FUNCTION public.f1(text)
 RETURNS text
 LANGUAGE plpgsql
AS $function$
begin
  raise exception 'only numeric type is supported';
end;
$function$

postgres=# select f1(10);
+----+
| f1 |
+----+
| 10 |
+----+
(1 row)

postgres=# select f1('ahoj');
ERROR:  only numeric type is supported
CONTEXT:  PL/pgSQL function f1(text) line 3 at RAISE

But strongly I don't recommend to use this pattern. Overloading is wild gun - can be good or bad friend, and should be used only when it is required and when it can do some work -  it should not be used for just raising a exception. This is job for postgres' type system - it does this work better (although with different and maybe on first view strange error message). 

