private static bool ValidateTitleCase(DataItemBase item, bool required) { if (required && !ValidateRequired(item)) { return(false); } // We always strip line breaks var value = item.DataControl.GetValue(); value = value.Replace(" \r\n", " "); value = value.Replace("\r\n ", " "); value = value.Replace("\r\n", " "); value = value.Replace(" \r", " "); value = value.Replace("\r ", " "); value = value.Replace("\r", " "); value = value.Replace(" \n", " "); value = value.Replace("\n ", " "); value = value.Replace("\n", " "); value = value.StripRedundantSpaces(); // We only recase if it's all upper to begin with if (value.IsAllUpperCase()) { value = value.ToTitleCase(); item.AddWarning("recased"); } item.DataControl.SetValue(value); return(true); }
private static bool ValidateTitleCase(DataItemBase item, bool required) { if (required && !ValidateRequired(item)) { return(false); } // We always strip line breaks var value = Regex.Replace(item.DataControl.GetValue(), @"[\r\n]+", " ").StripRedundantSpaces(); // We only recase if it's single case to begin with if (!value.IsMixedCase()) { value = value.ToTitleCase(); item.AddWarning("recased"); } item.DataControl.SetValue(value); return(true); }
private static bool ValidateSentenceCase(DataItemBase item, bool required) { if (required && !ValidateRequired(item)) { return(false); } var value = item.DataControl.GetValue(); value = value.StripRedundantSpaces(); // We only recase if it's all upper to begin with if (value.IsAllUpperCase()) { value = value.ToSentenceCase(); item.AddWarning("recased"); } item.DataControl.SetValue(value); return(true); }