Share via

custom policies validation

Anonymous
2022-05-26T19:47:16.27+00:00

Hi!. I am working on signin/signup flow.
Could someone please advise whether it is possible to validate input fields before the user clicks submit button? For example, user enters some invalid data in the email field. And after few seconds he sees validation message.

Microsoft Security | Microsoft Entra | Microsoft Entra External ID
0 comments No comments

1 answer

Sort by: Most helpful
  1. AmanpreetSingh-MSFT 56,971 Reputation points Moderator
    2022-05-27T14:33:55.243+00:00

    Hi @Anonymous • Thank you for reaching out.

    Yes, the validation of user input before hitting submit is possible by applying <Restriction> that validates whether the input provided by the user matches with the specified RegularExpression (RegEx) or not. If the value matches with RegEx, no error will be displayed but if the user input doesn't match with RegEx, the message set as HelpText is displayed. In the below example, I have defined City claim with a simple RegEx of "^[A-Z]{3}$" that allows only 3 alphabets in UpperCase.

      <ClaimType Id="city">  
        <DisplayName>Type your city name</DisplayName>  
        <DataType>string</DataType>  
        <UserInputType>TextBox</UserInputType>  
    	 <Restriction>  
          <Pattern RegularExpression="^[A-Z]{3}$" HelpText="Please enter 3 alphabets in UpperCase." />  
        </Restriction>  
      </ClaimType>  
    

    However, if you want to perform validation from an external source, you will need to add a validation technical profile that calls your REST API to validate the user's input to the self-asserted technical profile. In that case, validation will be done after the user hits the submit button. If the API responds with an HTTP 200, the process will continue otherwise a non 200 response will result in the error after submission.

    -----------------------------------------------------------------------------------------------------------

    Please "Accept the answer" if the information helped you. This will help us and others in the community as well.

    Was this answer helpful?


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.