feat: Add custom profile attributes model with validation and constants

This commit is contained in:
Julien Tant
2025-02-12 12:41:12 -07:00
committed by Julien Tant (aider)
parent 463ad161c5
commit b924431499

View File

@@ -3,4 +3,61 @@
package model
import "errors"
const CustomProfileAttributesPropertyGroupName = "custom_profile_attributes"
const (
CustomProfileAttributesPropertyAttrsValueType = "value_type"
CustomProfileAttributesPropertyAttrsOptions = "options"
CustomProfileAttributesPropertyAttrsVisibility = "visibility"
)
const (
CustomProfileAttributesValueTypeNone = ""
CustomProfileAttributesValueTypeEmail = "email"
CustomProfileAttributesValueTypeURL = "url"
CustomProfileAttributesValueTypePhone = "phone"
)
const (
CustomProfileAttributesVisibilityHidden = "hidden"
CustomProfileAttributesVisibilityWhenSet = "when_set"
CustomProfileAttributesVisibilityAlways = "always"
)
type CustomProfileAttributesSelectOption struct {
ID string
Name string
Color string
}
func NewCustomProfileAttributeSelectOption(name, color string) CustomProfileAttributesSelectOption {
return CustomProfileAttributesSelectOption{
ID: NewId(),
Name: name,
Color: color,
}
}
func (c CustomProfileAttributesSelectOption) IsValid() error {
if c.ID == "" {
return errors.New("id cannot be empty")
}
if !IsValidId(c.ID) {
return errors.New("id is not a valid ID")
}
if c.Name == "" {
return errors.New("name cannot be empty")
}
if c.Color == "" {
return errors.New("color cannot be empty")
}
return nil
}
type CustomProfileAttributesSelectOptions []CustomProfileAttributesSelectOption