Limit number of one-to-many relationships

In our application, we have the concept of a profile. A profile can have multiple services related to it. We want to be able to limit the number of services that can be related to one profile to say 7. How would be go about doing that? One consideration is that I would probably want to trigger a variant if the max number has been reached. I might also want to trigger a variant if there are no profiles related.