Escape string value to prevent encoding errors in ruby 1.9+ when validating