changing message for optional field error
# bot-training
r
I wonder if it possible to customize the error message thrown for missing mandatory error messages (for example return a lookup string for i18n for non-english Applications). Oc I could mark them as non-optional and write a custom validator but this seems like a bad workaround.
It is possible to do this. You should checkout the language translation docs: https://supertokens.com/docs/emailpassword/common-customizations/translations Essentially, you can provide a language translation mapping like shown below:
Copy code
tsx
import React from "react";
import SuperTokens from "supertokens-auth-react";

SuperTokens.init({
    languageTranslations: { // This object contains all translation related options
        translations: { // These are the displayed translation strings for each language
          // The property names define the language code of the translations
          en: {
            ERROR_NON_OPTIONAL: "<custom message here>", // for frontend validation error
            "Field is not optional": "<custom message here>" // for mapping message returned from the backend
          },
        },
    },
    appInfo: {
        appName: "...",
        apiDomain: "...",
        websiteDomain: "...",
    },
    recipeList: [
      // ...
    ],
});
supertokens-bot-test-case