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

@@ -32,6 +32,20 @@ pub struct UserProfile {
pub profile_fields: Vec<ProfileField>,
}
impl UserProfile {
pub const MAX_CUSTOM_FIELDS: usize = 4;
pub fn validate_custom_fields(fields: &[ProfileField]) -> Result<(), crate::errors::DomainError> {
if fields.len() > Self::MAX_CUSTOM_FIELDS {
Err(crate::errors::DomainError::ValidationError(
"Maximum 4 profile fields allowed".into(),
))
} else {
Ok(())
}
}
}
#[derive(Clone, Debug)]
pub struct User {
id: UserId,