Return 400 for invalid $uri and $args

Is there a way to check $uri and $args for invalid percent-encoded
utf8 string and return 400?