I want to create my own validation for images. With the v2.1 we got hooks - great.
I played with that, but it is a little bit strange to handle. Because a output throw all the time an js error.
As you said you want to create your own validation, Iād say you need to throw an error by throw new Exception('your error message'); within your hook function. And if all is valid, do nothing.
BTW - You might be totally aware of that, but just in case you are not: your hook function gets the $file not $page for this type of hook (panel.file.upload).