public PathValidation(PathValueIndexer <TSource> indexer, ValidationRuleFactory <TSource> factory) { Id = Guid.NewGuid(); Indexer = indexer; Path = indexer?.PathName; Factory = factory; }
public static PathValidation <JObject, TProperty> JObjectRuleFor <TProperty>(this ValidationRuleFactory <JObject> factory, JObjectFieldsBuilder <TProperty> fields) { var path = new JObjectPath(fields); return(factory.RuleForIf <TProperty>(path, null)); }
public ValidationRuleFactory <TSource> Clone(TSource newOriginalValue) { var result = new ValidationRuleFactory <TSource>(Repository, newOriginalValue); CopyTo(result); return(result); }
public ValidationRuleFactory <T> Create <T>(T value, Action <ValidationRuleFactory <T> > init = null) { var result = new ValidationRuleFactory <T>(this, value); init?.Invoke(result); return(result); }
public static PathValidation <TSource, TResult> Complex <TSource, TResult>(this PathValidation <TSource, TResult> validation, ValidationRuleFactory <TResult> rules) { validation.AddValidator(new ComplexRule <TResult>() { Factory = rules }); return(validation); }
private void CopyTo(ValidationRuleFactory <TSource> accum) { foreach (var t in m_validators) { accum.m_validators.Add(t.Clone()); } foreach (var t in m_conditions) { accum.m_conditions[t.Key] = t.Value; } }
public static PathValidation <TSource, TProperty> RuleFor <TSource, TProperty>(this ValidationRuleFactory <TSource> factory, Expression <Func <TSource, TProperty> > expression) { var path = PathValueIndexer <TSource> .m_factory.GetPathItems(expression); return(factory.RuleForIf <TProperty>(path, null)); }
public static PathValidation <JObject, TProperty> JObjectRuleForIf <TProperty>(this ValidationRuleFactory <JObject> factory, Func <JObjectFieldsBuilder, JObjectFieldsBuilder <TProperty> > fields, Func <JObject, bool> condition) { var path = new JObjectPath(fields(new JObjectFieldsBuilder())); return(factory.RuleForIf <TProperty>(path, condition)); }
public ValidationRuleFactory <TSource> Append(ValidationRuleFactory <TSource> otherFactory) { otherFactory.CopyTo(this); return(this); }