This reimplements a bunch of code that originally came from pages/article/ArticleHandler.inc.php in the validate() function, correct? If it's not possible to delegate to that code directly, it's best to a) note where the code came from, so that implementations can be kept synchronized, and b) keep this code as close to that code as possible so it's easy to compare them.