Drupal 7 trim user input and other checks to prevent security issues What is the recommended way in Drupal to perform trim and other checks before accepting user input to avoid sql injections and other similar security issues?

Thanks.
I recommend reading this article : 
https://www.drupal.org/writing-secure-code
Really a lot of good tips