Giter Club home page Giter Club logo

Comments (24)

kjetilge avatar kjetilge commented on July 28, 2024 1

I'll try to do your suggested workaround for now.
At least the front-end now has Norwgian translation 😀

from amplify-ui.

man-andy avatar man-andy commented on July 28, 2024 1

Any update on this?

from amplify-ui.

kjetilge avatar kjetilge commented on July 28, 2024

Looks like I can find answers to some of these quiestions here: customize-error-messages ?

from amplify-ui.

kjetilge avatar kjetilge commented on July 28, 2024

SO i tried this in a slot:

<amplify-authenticator>
  <amplify-sign-up
      :validation-errors="map"
  >
  </amplify-sign-up>
</amplify-authenticator>

and in methods:

methods: {
     map(message) {
      console.log('mess', message)
     if (/Username.*empty/i.test(message)) {
        return 'My error message'
      }
      return message
    }
}

This is not working either.
I wish this was better documented.

from amplify-ui.

ammarkarachi avatar ammarkarachi commented on July 28, 2024

@kjetilge The callback function for mock expects an error object here https://github.com/aws-amplify/amplify-cli/blob/858112e75fab7628b9a0f9cd95c08ff571dc707d/packages/amplify-util-mock/src/utils/lambda/execute.ts#L38

As for customizing the error message the JS team would be able to help you on that

from amplify-ui.

ashika01 avatar ashika01 commented on July 28, 2024

@kjetilge - Could you let us know which package you are using for UI?

from amplify-ui.

kjetilge avatar kjetilge commented on July 28, 2024

I'm using Vue

from amplify-ui.

kjetilge avatar kjetilge commented on July 28, 2024

@kjetilge The callback function for mock expects an error object here https://github.com/aws-amplify/amplify-cli/blob/858112e75fab7628b9a0f9cd95c08ff571dc707d/packages/amplify-util-mock/src/utils/lambda/execute.ts#L38

If I use an error-object I will get a useless message in the amplify-tost. As mentioned above tihis results in the message: myPreSignup failed with the following error: [object, object]

I should be able to somehow override the message "myPreSignup failed with the following error:"
b/c the mock output should mirror what is diaplyed in amplify-toast, not ?

from amplify-ui.

ashika01 avatar ashika01 commented on July 28, 2024

Making sure again, the link you have point to @aws-amplify/ui-vue. So if you are using that, you might not be able to change the error message. We started having discussions on this internally. we can mark this issue as Feature request and track the progress in this as we go along.

Workaround would be for you to create your custom UI using slots and pass the needed error message to amplify-toast component. Docs are here

from amplify-ui.

ashika01 avatar ashika01 commented on July 28, 2024

I dont completely understand your use case yet. Would it be possible to stringify the error object in case of failure so it shows up properly in toast?

from amplify-ui.

kjetilge avatar kjetilge commented on July 28, 2024

In I'm short I'm translating to norwegian.

from amplify-ui.

ashika01 avatar ashika01 commented on July 28, 2024

Yeah, we are basically looking at making use of i18n that we have to do this. So will keep you posted here.

from amplify-ui.

kjetilge avatar kjetilge commented on July 28, 2024

Is it possible to use the context.fail for anything ?

from amplify-ui.

ashika01 avatar ashika01 commented on July 28, 2024

What do you mean by context.fail?

from amplify-ui.

kjetilge avatar kjetilge commented on July 28, 2024

In your code I see:


    const context = {
      done(error, result) {
        if (!returned) {
          returned = true;
          if (error === null || typeof error === 'undefined') {
            context.succeed(result);
          } else {
            context.fail(error);
          }
        }
      },

from amplify-ui.

ashika01 avatar ashika01 commented on July 28, 2024

@ammarkarachi any thoughts?

from amplify-ui.

ashika01 avatar ashika01 commented on July 28, 2024

I see above this is your sample code,

if (!allowed) {
    callback({error: 'My error message'}, null);
  } else {
    callback(null, event);
  }

I was suggesting this, which should solve the toast problem

if (!allowed) {
    callback(JSON.stringify({error: 'My error message'}), null);
  } else {
    callback(null, event);
  }

from amplify-ui.

ammarkarachi avatar ammarkarachi commented on July 28, 2024

If I understand correctly you want to intercept the error message to translate it?

from amplify-ui.

kjetilge avatar kjetilge commented on July 28, 2024

@ashika01 I see, but I would still get the "myPreSignup failed with the following error:" in front of my message ?

from amplify-ui.

kjetilge avatar kjetilge commented on July 28, 2024

@ammarkarachi Yes. I want to intercept the error message for translatiopn.

from amplify-ui.

kjetilge avatar kjetilge commented on July 28, 2024

It is a litlle strange that passing values to validationErrors in SignUp in Vue UI component in does not fix this. Nothing happens when using it. It's like the funtion is not implemented.

from amplify-ui.

ashika01 avatar ashika01 commented on July 28, 2024

@kjetilge Yeah.. So now we use StencilJS to build our core UI and use stencil bindings to generate different framework's code. So some functionality might be missing.

from amplify-ui.

ericclemmons avatar ericclemmons commented on July 28, 2024

@Shomari asks in Discord (https://discord.com/channels/705853757799399426/708383821401161738/927239008185106452):

is there anyway to customize the UI error message? I mostly want to remove the first part about "PreSignUp failed with error" and only show my custom error message returned from lambda.
Not a huge deal but could be a little confusing for users wondering what PreSignUp is

The original bug for this issue may not be relevant, but customizing lambda messages are :)

from amplify-ui.

ErikCH avatar ErikCH commented on July 28, 2024

You can now update all error messages with i18n translations.
https://ui.docs.amplify.aws/components/authenticator#labels--text

Please reopen this issue if you still have problems.

from amplify-ui.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.