UiPath Form Designer - Validate 2 passwords

You can do it by adding a text field which has the error message, mark it as hidden by default
and showcase that error message whenever the text of these two components are not matched.

you can do this comparison with the help of Advanced condition option using JavaScript.

You can put the condition on the submit button to be disabled, if that text box component is visible

I posted a tutorial on how to use condition. I am sure this will help, do try it out.