you can't have both of these constraints in effect at the same time.
consider how these will be created - whichever one you create first will fail the constraint.
I think typically, the parent object, in your example the project, would not have a constraint about the children. however the child, in your example the task, would contain a NOT NULL column that was a Foreign Key to the parent.