Sanitize input based on spec