public IValidateRules <Contact> CreateUpdate() { var rules = new ValidateRules <Contact>(); rules.AddRule(x => x.Id != 0, "Id field must have a value"); rules.AddRule(x => x.UpdatedAt != DateTime.MinValue, "UpdatedAt field must be set"); return(rules); }
public IValidateRules <NoteFilter> CreateGet() { var rules = new ValidateRules <NoteFilter>(); rules.AddRule(f => string.IsNullOrEmpty(f.Element), "An element for note is not specified"); rules.AddRule(f => f.LimitOffset != 0 && f.LimitRows == 0, "Specify the LimitRows"); return(rules); }
public IValidateRules <Task> CreateUpdate() { var rules = new ValidateRules <Task>(); rules.AddRule(x => x.Id != 0, "Id field must have a value"); rules.AddRule(x => x.UpdatedAt != DateTime.MinValue, "UpdatedAt field must be set"); rules.AddRule(x => !String.IsNullOrEmpty(x.Text), "Text field can't be empty"); return(rules); }
public IValidateRules <Note> CreateAdd() { var rules = new ValidateRules <Note>(); rules.AddRule(x => x.ElementId != 0, "ElementId field must be set"); rules.AddRule(x => x.ElementType != 0, "ElementType field must be set"); rules.AddRule(x => x.NoteType != 0, "NoteType field must be set"); rules.AddRule(x => !String.IsNullOrEmpty(x.Text), "Text field can't be empty"); return(rules); }
public IValidateRules <Task> CreateAdd() { var rules = new ValidateRules <Task>(); rules.AddRule(x => x.ElementId != 0, "ElementId field must be set"); rules.AddRule(x => x.ElementType != 0, "ElementType field must be set"); rules.AddRule(x => x.TaskType != 0, "TaskType field must be set"); rules.AddRule(x => !String.IsNullOrEmpty(x.Text), "Text field can't be empty"); rules.AddRule(x => x.CompleteTillAt != DateTime.MinValue, "CompleteTillAt field must be set"); return(rules); }
public IValidateRules <Contact> CreateAdd() { var rules = new ValidateRules <Contact>(); rules.AddRule(x => !String.IsNullOrEmpty(x.Name), "Name field can't be empty"); return(rules); }
public void ValidateResultsLambdaExpressionHasText() { IValidateRules <ChekedClass> validator = new ValidateRules <ChekedClass>(); validator.AddRule(x => !String.IsNullOrEmpty(x.Name), "Error"); var obj = new ChekedClass() { Id = 123, isValue = true, Name = "", Reference = new object() }; Assert.AreEqual(validator.ValidateResults(obj).First().ErrorMessage, "Error"); }
public void ValidateResultsLambdaExpressionDoesntReturnsName() { IValidateRules <ChekedClass> validator = new ValidateRules <ChekedClass>(); validator.AddRule(x => !String.IsNullOrEmpty(x.Name), "Error"); var obj = new ChekedClass() { Id = 123, isValue = true, Name = "", Reference = new object() }; Assert.IsNull(validator.ValidateResults(obj).First().MemberNames.FirstOrDefault()); }
public void ValidateResultsBinaryExpressionHasText() { IValidateRules <ChekedClass> validator = new ValidateRules <ChekedClass>(); validator.AddRule(x => x.Id != 0, "Error"); var obj = new ChekedClass() { isValue = true, Name = "Name", Reference = new object() }; Assert.AreEqual(validator.ValidateResults(obj).First().ErrorMessage, "Error"); }
IValidateRules <ChekedClass> GetRules() { IValidateRules <ChekedClass> rules = new ValidateRules <ChekedClass>(); rules.AddRule(x => x.Id != 0, "Int should not be zero"); rules.AddRule(x => x.Name != "", "String should not be empty"); rules.AddRule(x => x.Name != null, "String should not be null"); rules.AddRule(x => !String.IsNullOrEmpty(x.Name), "String cheked by lambda"); rules.AddRule(x => x.isValue != false, "Bool should not be false"); rules.AddRule(x => x.Reference != null, "Object should not be null"); return(rules); }
public void AddRuleMessageException() { IValidateRules <ChekedClass> rules = new ValidateRules <ChekedClass>(); Assert.ThrowsException <ArgumentNullException>(() => rules.AddRule(x => x.Id == 0, "")); }
public void AddRulePredicatException() { IValidateRules <ChekedClass> rules = new ValidateRules <ChekedClass>(); Assert.ThrowsException <ArgumentNullException>(() => rules.AddRule(null, "message")); }