refactor: move profile-field count validation into domain UserProfile

This commit is contained in:
2026-06-10 03:13:19 +02:00
parent e9aa6131ae
commit d8cff33679
3 changed files with 39 additions and 6 deletions

View File

@@ -1,13 +1,9 @@
use domain::{errors::DomainError, events::DomainEvent, value_objects::UserId};
use domain::{errors::DomainError, events::DomainEvent, models::UserProfile, value_objects::UserId};
use crate::{context::AppContext, users::commands::UpdateProfileFieldsCommand};
pub async fn execute(ctx: &AppContext, cmd: UpdateProfileFieldsCommand) -> Result<(), DomainError> {
if cmd.fields.len() > 4 {
return Err(DomainError::ValidationError(
"Maximum 4 profile fields allowed".into(),
));
}
UserProfile::validate_custom_fields(&cmd.fields)?;
let user_id = UserId::from_uuid(cmd.user_id);
ctx.repos
.profile_fields