js: validator: add callback to validate() function