public override bool Execute(JObject rowJObject, string columnName = "") { var data = base.GetData(rowJObject, columnName); if (data == null || string.IsNullOrEmpty(data.ToString())) { return(true); } string regexString = RuleData.ToString();// ObjectUtils.GetJobjectPropertyValue(RuleData, "value"); if (string.IsNullOrEmpty(regexString)) { return(true); } try { Regex regex = new Regex(regexString); var isMatch = regex.IsMatch(data.ToString()); if (!isMatch) { base.MarkError(rowJObject, string.Format(ErrorMessage, columnName)); } return(isMatch); } catch (Exception ex) { //TODO: log the exception return(false); } }
public override bool Execute(JObject rowJObject, string columnName = "") { var data = base.GetData(rowJObject, columnName); var list = RuleData.ToString().Split(","); return(data == null || string.IsNullOrEmpty(data.ToString()) || data.ToString().Trim().Length == 0 || list.Contains(data.ToString())); }
private int GetRuleData() { int ruleData = 0; if (RuleData != null && Int32.TryParse(RuleData.ToString(), out ruleData)) { return(ruleData); } return(ruleData); }
private bool GetRequiredRuleData() { var truthy = new string[] { "TRUE", "YES", "1" }; try { if (RuleData.GetType() == typeof(bool)) { return((bool)RuleData); } bool convertedRuleData = truthy.Contains(RuleData.ToString().ToUpperInvariant()) ? true : false; return(convertedRuleData); } catch (System.Exception) { return(false); } }
public override bool Execute(JObject rowJObject, string columnName = "") { var data = base.GetData(rowJObject, columnName); if (data == null || data.ToString() == "") { return(true); } var ruleData = RuleData.ToString().ToLower(); var dataTypeParser = DataTypeParserBase.Create(ruleData); ErrorMessage = "Unable to convert '{0}' to datatype " + ruleData; var canParse = dataTypeParser.CanParse(data); if (canParse) { ParsedData = dataTypeParser.ParsedData; } if (!canParse) { base.MarkError(rowJObject, string.Format(ErrorMessage, columnName)); } return(canParse); }