Fix for passing arrays as values

As of now if you pass an array as a value, trim will throw a warning.
I also tweaked the sanitize method to return null in case of an array being passed as a value to prevent further issues.