I try to add a constraint based on geometry type to a "street" table that prevents anything except Linestring geometry or Null.
alter table streets add constraint streets_geom_linestring_chk check(st_geometrytype(geom) = 'ST_LINESTRING'::text OR geom IS NULL);
When I try to store geometries in the table:
update streets set geom=st_geomfromtext('LINESTRING(0 8,12 8)') where id=1;
I got an error, that the new row for relation violates check constraint.