I think the logic is too complicated for a CHECK constraint, and I haven't managed to get a user-defined function to work it that context so it may not be possible that way.
Results that may be inaccessible to you are currently showing.
Hide inaccessible results