changing message for optional field error


04/02/2023, 4:39 PM
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: Essentially, you can provide a language translation mapping like shown below:
import React from "react";
import SuperTokens from "supertokens-auth-react";

    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: [
      // ...