feat: Add validation to prevent empty custom profile attribute options

This commit is contained in:
Julien Tant (aider)
2025-02-12 12:49:00 -07:00
parent 1baece68f9
commit eac47527d2
2 changed files with 5 additions and 2 deletions
@@ -66,8 +66,11 @@ func (c CustomProfileAttributesSelectOption) IsValid() error {
type CustomProfileAttributesSelectOptions []CustomProfileAttributesSelectOption
func (c CustomProfileAttributesSelectOptions) IsValid() error {
seenNames := make(map[string]struct{})
if len(c) == 0 {
return errors.New("options list cannot be empty")
}
seenNames := make(map[string]struct{})
for _, option := range c {
if err := option.IsValid(); err != nil {
return err
@@ -101,7 +101,7 @@ func TestCustomProfileAttributesSelectOptionsIsValid(t *testing.T) {
{
name: "empty options",
options: CustomProfileAttributesSelectOptions{},
wantErr: "",
wantErr: "options list cannot be empty",
},
{
name: "valid options",