You can do a check constraint on the column based ...
# sql
g
You can do a check constraint on the column based on 1 or more other columns, or a before trigger with a function to check both columns for your requirements. Just google postgres and column constraint or before trigger function for ideas, or give more info on details.