If you have complex logic to validate then use code editor.
You need to choose the option "validate". The event checks for Boolean as return value, so your code logic should return either true or false. I would suggest start with a simple code in validate and I will continue to share inputs with you.
Thanks,
Mayank