public override IRow Operate(IRow row) { if (IsInvalid(row, _regex.Match(GetString(row, _input)).Success)) { AppendMessage(row, _betterFormat.Format(row)); } return(row); }
public override IRow Operate(IRow row) { if (IsInvalid(row, _func(row))) { AppendMessage(row, _betterFormat.Format(row)); } return(row); }
public override IRow Operate(IRow row) { if (IsInvalid(row, GetString(row, _input) == string.Empty)) { AppendMessage(row, _betterFormat.Format(row)); } return(row); }
public override IRow Operate(IRow row) { if (IsInvalid(row, _isCompatible || _canConvert(GetString(row, _input)))) { AppendMessage(row, _betterFormat.Format(row)); } return(row); }
public override IRow Operate(IRow row) { if (IsInvalid(row, GetString(row, _input).Length == Context.Operation.Length)) { AppendMessage(row, _betterFormat.Format(row)); } return(row); }
public override IRow Operate(IRow row) { if (IsInvalid(row, !row[_input].Equals(_default))) { AppendMessage(row, _betterFormat.Format(row)); } return(row); }
public override IRow Operate(IRow row) { var valid = GetString(row, _input).EndsWith(Context.Operation.Value); if (IsInvalid(row, valid)) { AppendMessage(row, _betterFormat.Format(row)); } return(row); }
public override IRow Operate(IRow row) { var valid = _map.Contains(row[_input]); row[ValidField] = valid; if (!valid) { AppendMessage(row, _betterFormat.Format(row)); } return(row); }
public override IRow Operate(IRow row) { var valid = row[_input].Equals(_default); row[ValidField] = valid; if (!valid) { AppendMessage(row, _betterFormat.Format(row)); } Increment(); return(row); }
public override IRow Operate(IRow row) { var valid = _func(row); row[ValidField] = valid; if (!valid) { AppendMessage(row, _betterFormat.Format(row)); } return(row); }
public override IRow Operate(IRow row) { var valid = GetString(row, _input).Length == Context.Operation.Length; row[ValidField] = valid; if (!valid) { AppendMessage(row, _betterFormat.Format(row)); } return(row); }
public override IRow Operate(IRow row) { var valid = _regex.IsMatch(GetString(row, _input)); row[ValidField] = valid; if (!valid) { AppendMessage(row, _betterFormat.Format(row)); } return(row); }
public override IRow Operate(IRow row) { var valid = GetString(row, _input).EndsWith(Context.Operation.Value); row[ValidField] = valid; if (!valid) { AppendMessage(row, _betterFormat.Format(row)); } Increment(); return(row); }
public override IRow Operate(IRow row) { var valid = GetString(row, _input) == string.Empty; row[ValidField] = valid; if (!valid) { AppendMessage(row, _betterFormat.Format(row)); } Increment(); return(row); }
public override IRow Operate(IRow row) { var text = _valueIsField ? GetString(row, _valueField) : Context.Operation.Value; var valid = _isValid(row, text); if (IsInvalid(row, valid)) { AppendMessage(row, _betterFormat.Format(row)); } return(row); }
public override IRow Operate(IRow row) { var valueItMustContain = _valueIsField ? GetString(row, _valueField) : Context.Operation.Value; var valid = _input.Any(f => GetString(row, f).Contains(valueItMustContain)); if (IsInvalid(row, valid)) { AppendMessage(row, _betterFormat.Format(row)); } return(row); }
public override IRow Operate(IRow row) { var valid = _isCompatible || _canConvert(GetString(row, _input)); row[ValidField] = valid; if (!valid) { AppendMessage(row, _betterFormat.Format(row)); } Increment(); return(row); }
public override IRow Operate(IRow row) { var valueItMustContain = _valueIsField ? GetString(row, _valueField) : Context.Operation.Value; var valid = _input.Any(f => GetString(row, f).Contains(valueItMustContain)); row[ValidField] = valid; if (!valid) { AppendMessage(row, _betterFormat.Format(row)); } Increment(); return(row); }
public override IRow Operate(IRow row) { var match = _regex.Match(GetString(row, _input)); row[ValidField] = match.Success; if (!match.Success) { AppendMessage(row, _betterFormat.Format(row)); } return(row); }
public override IEnumerable <IRow> Operate(IEnumerable <IRow> rows) { /* Over ride Operate(IEnumerable<IRow>) to load the map, which may not be available at start up */ foreach (var item in CreateMap().Items) { _map.Add(_input.Convert(item.From)); } var help = Context.Field.Help; if (help == string.Empty) { if (_autoMap || _map.Count > 5) { help = $"{Context.Field.Label}'s value {{{Context.Field.Alias}}} is {(_inMap ? "not one of" : "one of")} {_map.Count} {(_inMap ? "valid" : "invalid")} items."; } else { var domain = Utility.ReadableDomain(_map); if (domain == string.Empty) { help = $"{Context.Field.Label} has an empty {Context.Operation.Method} validator."; } else { help = $"{Context.Field.Label}'s value {{{Context.Field.Alias}}} must {(_inMap ? "be" : "not be")} one of these {_map.Count} items: " + domain + "."; } } } _betterFormat = new BetterFormat(Context, help, Context.Entity.GetAllFields); Func <object, bool> isValid; if (_inMap) { isValid = o => _map.Contains(o); } else { isValid = o => !_map.Contains(o); } /* when you override Operate(IEnumerable<IRow>) you must add your ShouldRun check, if you want it */ if (Context.Operation.ShouldRun == null) { _validate = row => { if (IsInvalid(row, isValid(row[_input]))) { AppendMessage(row, _betterFormat.Format(row)); } }; } else { _validate = row => { if (Context.Operation.ShouldRun(row) && IsInvalid(row, isValid(row[_input]))) { AppendMessage(row, _betterFormat.Format(row)); } }; } return(rows.Select(Operate)); }
public override IEnumerable <IRow> Operate(IEnumerable <IRow> rows) { /* Over ride Operate(IEnumerable<IRow>) to load the map, which may not be available at start up */ var mapItems = CreateMap().Items; var usingTo = mapItems.Any(mi => !mi.To.Equals(Constants.DefaultSetting)); foreach (var item in CreateMap().Items) { var from = _input.Convert(item.From); if (usingTo) { var to = _input.Convert(item.To); _map[to.Equals(Constants.DefaultSetting) ? from : to] = from; } else { _map[from] = from; } } var help = Context.Field.Help; if (help == string.Empty) { if (_autoMap || _map.Count > 5) { if (usingTo) { help = $"{Context.Field.Label} is {(_inMap ? "not one of" : "one of")} {_map.Count} {(_inMap ? "valid" : "invalid")} items."; } else { help = $"{Context.Field.Label}'s value {{{Context.Field.Alias}}} is {(_inMap ? "not one of" : "one of")} {_map.Count} {(_inMap ? "valid" : "invalid")} items."; } } else { var domain = Utility.ReadableDomain(_map.Values); if (domain == string.Empty) { help = $"{Context.Field.Label} has an empty {Context.Operation.Method} validator."; } else { if (usingTo) { help = $"{Context.Field.Label} must {(_inMap ? "be" : "not be")} one of these {_map.Count} items: " + domain + "."; } else { help = $"{Context.Field.Label}'s value {{{Context.Field.Alias}}} must {(_inMap ? "be" : "not be")} one of these {_map.Count} items: " + domain + "."; } } } } _betterFormat = new BetterFormat(Context, help, Context.Entity.GetAllFields); Func <object, bool> isValid; if (_inMap) { // isValid = o => _map.Contains(o); isValid = o => _map.ContainsKey(o); } else { // isValid = o => !_map.Contains(o); isValid = o => !_map.ContainsKey(o); } _validate = row => { if (IsInvalid(row, isValid(row[_input]))) { AppendMessage(row, _betterFormat.Format(row)); } }; return(rows.Select(Operate)); }