feat: email uniqueness constraint between user and member

This commit is contained in:
Moritz 2025-10-17 14:21:23 +02:00
parent 5a0a261cd6
commit 39afaf3999
Signed by: moritz
GPG key ID: 1020A035E5DD0824
5 changed files with 329 additions and 6 deletions

View file

@ -108,6 +108,10 @@ defmodule Mv.Membership.Member do
validate present(:last_name)
validate present(:email)
# Email uniqueness check for all actions that change the email attribute
# Validates that member email is not already used by another (unlinked) user
validate Mv.Membership.Member.Validations.EmailNotUsedByOtherUser
# Prevent linking to a user that already has a member
# This validation prevents "stealing" users from other members by checking
# if the target user is already linked to a different member