FIX: Validate value of custom user fields (dropdowns and multiple selects) (PR #13890)

This PR is to address this issue from meta: https://meta.discourse.org/t/validation-of-dropdown-custom-user-fields/198132

GitHub

This is just my preference, and I know you didn’t make it this way to start, but can you change f to field here? I really dislike abbreviations for short variables, they just make it so much harder for me to read!

I really like the specs here, nice work. Only leaving a small suggestion

I feel the same as you. Also val could be value :wink:

              put update_user_url, params: { user_fields: { field_id => "This option doesn't exist" } }

The title of this pull request changed from “FIX: Validate value of custom dropdown user fields” to "FIX: Validate value of custom user fields (dropdowns and multiple selects)

Looks good!

I’m wondering if all this logic should be moved into clean_custom_field_values

I think we could, although the method would be slightly longer. I’m going to leave it here for simplicity, for now.