duplicate email check in tutorial 6

duplicate email check in tutorial 6

  
Has anybody done tutorial 6?

In this tutorial there is a challenge to create a validation rule when
editing/creating contacts to check that the email address doesn't
already exist. The normal solution would be to set the Email field to
primary key/unique index but the tutorial states specifically to
create a validation rule in AP. I'm curious as to how it's done.
Creating a unique index on the email attribute prevents you from creating repeated email in the Database, but an ugly DB exception is thrown when the CreateOrUpdate entity action is called, and you don't want to show that to the end-user. So what you should do is to check if the email is repeated before the CreateOrUpdate, in order to be able to give a nice error message to the user.

Check the attached example file, where I've did both (the unique index and the validation).

PS: In 5.1, when creating an edit screen using IntelliWarp, these kinds of validations are automatically done for you if the entity has unique indices