simplified and improved check of null string in validate()