mirror of
https://github.com/discourse/discourse.git
synced 2025-01-18 11:02:46 +08:00
69193c4bd5
# 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 |
||
---|---|---|
.. | ||
admin | ||
custom-proxy | ||
deprecation-silencer | ||
dialog-holder | ||
discourse | ||
discourse-common | ||
discourse-hbr | ||
discourse-i18n | ||
discourse-markdown-it | ||
discourse-plugins | ||
discourse-widget-hbs | ||
docs | ||
ember-addons | ||
ember-cli-progress-ci | ||
ember-production-deprecations | ||
float-kit | ||
locales | ||
pretty-text | ||
select-kit | ||
theme-transpiler | ||
truth-helpers | ||
.npmrc | ||
handlebars-shim.js | ||
polyfills.js | ||
run-patch-package | ||
service-worker.js.erb |