Contentful logo

Contentful Community

Validation within dialog type prompt

Hello,
I have a dialog that displays the user a prompt type dialog. The idea is that the user is requesting a resource-intensive request and I want to make sure that they are sure that they want to make the request.

Following the same pattern in AWS || GitHub, i.e. to make sure that a user wants to delete an S3 bucket, the user will have to type the name of the S3 bucket or the name of the GitHub repository.

const modelOptions = {
title: ‘Confirm’,
message:
‘Please confirm the request to generate PDF output by typing, CONFIRM, in the text box. A email will be sent out when the request is processed’,
intent: ‘negative’,
confirmLabel: ‘Yes!’,
cancelLabel: ‘No…’,
placeHolderText: ‘type the requested word here’,
};
const confirmationString = await sdk.dialogs.openPrompt(modelOptions);

My two questions are:

  1. Do we have the option to pass the placeHolderText?
  2. I want to prompt an error if the user types anything else apart from CONFIRM, can I pass the word validation as a modelOption?

Hi @parik.tiwari, are you building a UI extension for the Web App?

If so, these links might help you:
https://www.contentful.com/developers/docs/extensibility/ui-extensions/sdk-reference/

However to be able to better support you, could you tell me which documentation are you using? It’s a very particular JavaScript question, and I want to be sure the eventual response I’ll give you is correct.