Function isValidString

Validates a string value. Returns the string if valid, otherwise returns the provided defaultValue or an empty string.