Custom Function to block creation of an Activity -> Task

Custom Function to block creation of an Activity -> Task

Dear,

I need a code template to create a custom function that meets the following criteria:

When creating an Activity -> Task, is validated the value entered in the date field if the date entered is not less than the current date (-2 days).

If you are under, prevent the creation of the Task.