refactor: move profile-field count validation into domain UserProfile
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user