discourse/app
Isaac Janzen 69193c4bd5
DEV: Add a callback to the validation of user custom fields in the signup form (#27369)
# Description

Add `addCustomUserFieldValidationCallback` to the user fields validation mixin. This allows you to add a custom validation when checking the validity of custom user field values in the signup form on submit. 

```js
addCustomUserFieldValidationCallback((userField) => {
  if (userField.field.name === "my custom user field" && userField.value === "foo") {
    return EmberObject.create({
      failed: true,
      reason: I18n.t("value_can_not_be_foo"),
      element: userField.field.element,
    });
  }
});
```

In the case your custom validation deems an input value `failed`, you return an EmberObject with the fields `failed: true`, `reason`, and `element`.

```js
return EmberObject.create({
  failed: true,
  reason: I18n.t("value_can_not_be_foo"),
  element: userField.field.element,
});
```

which will then display your custom `reason` to the user attached to the given user custom field input and will not submit the signup form.

<img width="288" alt="Screenshot 2024-06-06 at 11 08 40 AM" src="https://github.com/discourse/discourse/assets/50783505/11168fb8-8806-43f0-9417-73991bbd1178">

# Other

- Add `addCustomUserFieldValidationCallback` to the plugin api
- Bump plugin api version
- Update plugin api changelog
- Add tests
2024-06-06 11:17:06 -06:00
..
assets DEV: Add a callback to the validation of user custom fields in the signup form (#27369) 2024-06-06 11:17:06 -06:00
controllers FIX: User can't reset password with backup codes when only security key is enabled (#27368) 2024-06-06 14:30:42 +08:00
helpers DEV: Update to lastest rubocop-discourse 2024-05-27 18:06:14 +02:00
jobs DEV: Update to lastest rubocop-discourse 2024-05-27 18:06:14 +02:00
mailers FIX: correctly compute the window for email summaries 2024-05-27 22:33:51 +02:00
models FEATURE: the ability to change the order of flags (#27269) 2024-06-05 13:27:06 +10:00
serializers FEATURE: the ability to change the order of flags (#27269) 2024-06-05 13:27:06 +10:00
services DEV: Avoid unique validation in UserPasswordExpirer.expire_user_password (#27343) 2024-06-05 15:22:40 +08:00
views FIX: send activity summaries based on "last seen" (#27035) 2024-05-22 10:23:03 +02:00