That's not the intended use of front-end validation. The custom option only allows you to create an expression that will be checked.
If you want to make a custom validation, it's best to do it in a microflow, and place it under the save button.
I partially agree with Lennart. You could do the validation in a microflow in a save flow, but if you want to provide the user with immediate feedback you could also easily build an on change microflow. You can do this in the “Events” tab.
What would probably also be better and even better: use a nanoflow in stead of a microflow. Then the validation is done client side. Use a ‘validation feedback’ message to show the validation on the right attribute.