mirror of
https://github.com/discourse/discourse.git
synced 2024-11-25 02:11:08 -06: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-QUICK-START-GUIDE.md | ||
AUTHORS.md | ||
CHANGELOG-JAVASCRIPT-PLUGIN-API.md | ||
code-of-conduct.md | ||
DEVELOPER-ADVANCED.md | ||
DEVELOPMENT-OSX-NATIVE.md | ||
INSTALL-cloud.md | ||
INSTALL-email.md | ||
INSTALL.md | ||
PLUGINS.md | ||
SECURITY.md | ||
TESTING.md | ||
TROUBLESHOOTING.md |