feat: removes phoen number as member field and makes name optional
This commit is contained in:
parent
844b4b6409
commit
17540c6b1d
3 changed files with 405 additions and 20 deletions
|
|
@ -5,7 +5,7 @@ defmodule Mv.Membership.Member do
|
|||
## Overview
|
||||
Members are the core entity in the membership management system. Each member
|
||||
can have:
|
||||
- Personal information (name, email, phone, address)
|
||||
- Personal information (name, email, address)
|
||||
- Optional link to a User account (1:1 relationship)
|
||||
- Dynamic custom field values via CustomField system
|
||||
- Full-text searchable profile
|
||||
|
|
@ -20,9 +20,8 @@ defmodule Mv.Membership.Member do
|
|||
- `has_one :user` - Optional authentication account link
|
||||
|
||||
## Validations
|
||||
- Required: first_name, last_name, email
|
||||
- Required: email (all other fields are optional)
|
||||
- Email format validation (using EctoCommons.EmailValidator)
|
||||
- Phone number format: international format with 6-20 digits
|
||||
- Postal code format: exactly 5 digits (German format)
|
||||
- Date validations: join_date not in future, exit_date after join_date
|
||||
- Email uniqueness: prevents conflicts with unlinked users
|
||||
|
|
@ -31,7 +30,7 @@ defmodule Mv.Membership.Member do
|
|||
Members have a `search_vector` attribute (tsvector) that is automatically
|
||||
updated via database trigger. Search includes name, email, notes, contact fields,
|
||||
and all custom field values. Custom field values are automatically included in
|
||||
the search vector with weight 'C' (same as phone_number, city, etc.).
|
||||
the search vector with weight 'C' (same as city, etc.).
|
||||
"""
|
||||
use Ash.Resource,
|
||||
domain: Mv.Membership,
|
||||
|
|
@ -343,9 +342,7 @@ defmodule Mv.Membership.Member do
|
|||
validations do
|
||||
# Required fields are covered by allow_nil? false
|
||||
|
||||
# First name and last name must not be empty
|
||||
validate present(:first_name)
|
||||
validate present(:last_name)
|
||||
# Email is required
|
||||
validate present(:email)
|
||||
|
||||
# Email uniqueness check for all actions that change the email attribute
|
||||
|
|
@ -396,11 +393,6 @@ defmodule Mv.Membership.Member do
|
|||
where: [present([:join_date, :exit_date])],
|
||||
message: "cannot be before join date"
|
||||
|
||||
# Phone number format (only if set)
|
||||
validate match(:phone_number, ~r/^\+?[0-9\- ]{6,20}$/),
|
||||
where: [present(:phone_number)],
|
||||
message: "is not a valid phone number"
|
||||
|
||||
# Postal code format (only if set)
|
||||
validate match(:postal_code, ~r/^\d{5}$/),
|
||||
where: [present(:postal_code)],
|
||||
|
|
@ -453,12 +445,12 @@ defmodule Mv.Membership.Member do
|
|||
uuid_v7_primary_key :id
|
||||
|
||||
attribute :first_name, :string do
|
||||
allow_nil? false
|
||||
allow_nil? true
|
||||
constraints min_length: 1
|
||||
end
|
||||
|
||||
attribute :last_name, :string do
|
||||
allow_nil? false
|
||||
allow_nil? true
|
||||
constraints min_length: 1
|
||||
end
|
||||
|
||||
|
|
@ -474,10 +466,6 @@ defmodule Mv.Membership.Member do
|
|||
constraints min_length: 5, max_length: 254
|
||||
end
|
||||
|
||||
attribute :phone_number, :string do
|
||||
allow_nil? true
|
||||
end
|
||||
|
||||
attribute :join_date, :date do
|
||||
allow_nil? true
|
||||
end
|
||||
|
|
@ -1073,7 +1061,6 @@ defmodule Mv.Membership.Member do
|
|||
expr(
|
||||
contains(postal_code, ^query) or
|
||||
contains(house_number, ^query) or
|
||||
contains(phone_number, ^query) or
|
||||
contains(email, ^query) or
|
||||
contains(city, ^query)
|
||||
)
|
||||
|
|
|
|||
|
|
@ -7,7 +7,6 @@ defmodule Mv.Constants do
|
|||
:first_name,
|
||||
:last_name,
|
||||
:email,
|
||||
:phone_number,
|
||||
:join_date,
|
||||
:exit_date,
|
||||
:notes,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue