discourse/app/assets/javascripts
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
..
admin DEV: Initial UI for admin config area for /about (#27340) 2024-06-06 16:07:08 +03:00
custom-proxy Build(deps-dev): Bump glob from 10.3.16 to 10.4.1 (#27186) 2024-05-27 11:41:43 +02:00
deprecation-silencer DEV: Silence whitespace-eating-comment warnings (#27129) 2024-05-22 16:21:51 +02:00
dialog-holder Build(deps): Bump ember-auto-import from 2.7.2 to 2.7.3 (#27235) 2024-05-29 08:14:00 +08:00
discourse DEV: Add a callback to the validation of user custom fields in the signup form (#27369) 2024-06-06 11:17:06 -06:00
discourse-common Build(deps): Bump the babel group with 2 updates (#27361) 2024-06-06 01:46:03 +02:00
discourse-hbr DEV: Convert discourse-hbr to a regular package (#26562) 2024-04-08 20:00:34 +01:00
discourse-i18n Build(deps): Bump @embroider/addon-shim in the embroider group (#27142) 2024-05-23 00:32:09 +02:00
discourse-markdown-it Build(deps): Bump ember-auto-import from 2.7.2 to 2.7.3 (#27235) 2024-05-29 08:14:00 +08:00
discourse-plugins Build(deps): Bump the babel group with 2 updates (#27361) 2024-06-06 01:46:03 +02:00
discourse-widget-hbs Build(deps): Bump the babel group with 2 updates (#27361) 2024-06-06 01:46:03 +02:00
docs
ember-addons
ember-cli-progress-ci PERF: Improve production JS build in low-memory environments (#26849) 2024-05-02 11:43:59 +01:00
ember-production-deprecations DEV: Drop unused shims for Ember 3 deprecations (#26563) 2024-04-09 09:22:37 +01:00
float-kit Build(deps): Bump the babel group with 2 updates (#27361) 2024-06-06 01:46:03 +02:00
locales FEATURE: Add Uyghur language (#27183) 2024-05-27 09:58:18 +02:00
pretty-text Build(deps): Bump the babel group with 2 updates (#27361) 2024-06-06 01:46:03 +02:00
select-kit Build(deps): Bump the babel group with 2 updates (#27361) 2024-06-06 01:46:03 +02:00
theme-transpiler Build(deps): Bump the babel group with 2 updates (#27361) 2024-06-06 01:46:03 +02:00
truth-helpers Build(deps): Bump ember-auto-import from 2.7.2 to 2.7.3 (#27235) 2024-05-29 08:14:00 +08:00
.npmrc
handlebars-shim.js
polyfills.js
run-patch-package
service-worker.js.erb DEV: Drop workbox dependency (#26735) 2024-04-24 10:19:12 +01:00