Correct way to validate CPF numbers.

its not mandatory that the CPF should have a format like 000.000.000-00. Only numbers is also valid. So I'm always cleaning the field value in order to make a accurate validation.