public static string Underscore(string str) { if (str == null) return null; str = Regex.Replace(str, @"([A-Z]+)([A-Z][a-z])", "$1_$2"); return Regex. Replace(str, @"([a-z])([A-Z])", "$1_$2"). Replace("-", "_"). ToLower(); } }
public virtual List <ValidationError> OnField(string fieldName) { string key = StringUtil.Underscore(fieldName); if (errors.ContainsKey(key)) { return(errors[key]); } return(null); }