I wouldn't do this at database level, unless the people using it are going to be directly modifying the database tables (which would be a bad idea).
This sort of data dependent validation belongs in the application layer, not the database itself.
If you really want to do it, you would be looking to add a check constraint.