String validation and sanitization