update detection and isValid* to use filter_var() when possible.