Re-implemented the casting filters using filter_var().