add validator for middleware