protected virtual string ValidateArchivePassword(string password, string label, Action onError, bool contentIsRequired = true) { var errors = new List<IActionableErrorInfo>(); RuleSet fileActivityRuleSet = new RuleSet(); IsValidExpressionRule isValidExpressionRule = new IsValidExpressionRule(() => password, DataListSingleton.ActiveDataList.Resource.DataList); fileActivityRuleSet.Add(isValidExpressionRule); errors.AddRange(fileActivityRuleSet.ValidateRules(label, onError)); UpdateErrors(errors); return password; }
public override IRuleSet GetRuleSet(string propertyName, string datalist) { var ruleSet = new RuleSet(); if(IsEmpty()) { return ruleSet; } switch(propertyName) { case "OutputVariable": var outputExprRule = new IsValidExpressionRule(() => OutputVariable,datalist, "1"); ruleSet.Add(outputExprRule); ruleSet.Add(new IsValidExpressionRule(() => outputExprRule.ExpressionValue, datalist)); if(!string.IsNullOrEmpty(XPath)) { ruleSet.Add(new IsStringEmptyRule(() => OutputVariable)); } break; case "XPath": if(!string.IsNullOrEmpty(OutputVariable)) { ruleSet.Add(new IsStringEmptyRule(() => XPath)); if(!string.IsNullOrEmpty(XPath) && !DataListUtil.IsEvaluated(XPath)) { ruleSet.Add(new IsValidXpathRule(() => XPath)); } } break; } return ruleSet; }
public override IRuleSet GetRuleSet(string propertyName, string datalist) { RuleSet ruleSet = new RuleSet(); if (IsEmpty()) { return ruleSet; } switch (propertyName) { case "FieldName": if(FieldName.Length == 0) { ruleSet.Add(new IsStringEmptyRule(() => FieldName)); } break; case "ValueToMatch": if(ValueToMatch.Length == 0) { ruleSet.Add(new IsStringEmptyRule(() => ValueToMatch)); } ruleSet.Add(new IsValidExpressionRule(() => ValueToMatch, datalist, "1")); break; } return ruleSet; }
protected virtual string ValidatePath(string label, string path, Action onError, bool pathIsRequired) { if (!pathIsRequired && string.IsNullOrWhiteSpace(path)) { return string.Empty; } var errors = new List<IActionableErrorInfo>(); RuleSet fileActivityRuleSet = new RuleSet(); IsValidExpressionRule isValidExpressionRule = new IsValidExpressionRule(() => path, DataListSingleton.ActiveDataList.Resource.DataList); fileActivityRuleSet.Add(isValidExpressionRule); errors.AddRange(fileActivityRuleSet.ValidateRules(label, onError)); string pathValue; path.TryParseVariables(out pathValue, onError, variableValue: ValidUriSchemes[0] + "://temp"); if (errors.Count == 0) { IsStringEmptyOrWhiteSpaceRule isStringEmptyOrWhiteSpaceRuleUserName = new IsStringEmptyOrWhiteSpaceRule(() => path) { LabelText = label, DoError = onError }; IsValidFileNameRule isValidFileNameRule = new IsValidFileNameRule(() => path) { LabelText = label, DoError = onError }; fileActivityRuleSet.Add(isStringEmptyOrWhiteSpaceRuleUserName); fileActivityRuleSet.Add(isValidExpressionRule); errors.AddRange(fileActivityRuleSet.ValidateRules(label, onError)); } UpdateErrors(errors); return pathValue; }
public override IRuleSet GetRuleSet(string propertyName, string datalist) { RuleSet ruleSet = new RuleSet(); if (IsEmpty()) { return ruleSet; } switch (propertyName) { case "Input": if (!string.IsNullOrEmpty(InputVariable)) { var inputExprRule = new IsValidExpressionRule(() => InputVariable, datalist, "0"); ruleSet.Add(inputExprRule); } else ruleSet.Add(new IsStringEmptyRule(() => InputVariable)); break; case "At": if (MergeType == MergeTypeIndex) { var atExprRule = new IsValidExpressionRule(() => At, datalist, "1"); ruleSet.Add(atExprRule); ruleSet.Add(new IsStringEmptyRule(() => atExprRule.ExpressionValue)); ruleSet.Add(new IsPositiveNumberRule(() => atExprRule.ExpressionValue)); } break; case "Padding": if (!string.IsNullOrEmpty(Padding)) { var paddingExprRule = new IsValidExpressionRule(() => Padding, datalist, "0"); ruleSet.Add(paddingExprRule); ruleSet.Add(new IsSingleCharRule(() => paddingExprRule.ExpressionValue)); } break; } return ruleSet; }
public override IRuleSet GetRuleSet(string propertyName, string datalist) { var ruleSet = new RuleSet(); if(IsEmpty()) { return ruleSet; } switch(propertyName) { case "OutputVariable": if (!string.IsNullOrEmpty(OutputVariable)) { var outputExprRule = new IsValidExpressionRule(() => OutputVariable, datalist, "0"); ruleSet.Add(outputExprRule); ruleSet.Add(new IsValidExpressionRule(() => outputExprRule.ExpressionValue, datalist)); } break; case "At": switch(SplitType) { case SplitTypeIndex: var atIndexExprRule = new IsValidExpressionRule(() => At, datalist, "1"); ruleSet.Add(atIndexExprRule); ruleSet.Add(new IsPositiveNumberRule(() => atIndexExprRule.ExpressionValue)); break; case SplitTypeChars: var atCharsExprRule = new IsValidExpressionRule(() => At, datalist, ","); ruleSet.Add(atCharsExprRule); ruleSet.Add(new IsStringEmptyRule(() => atCharsExprRule.ExpressionValue)); break; } break; } return ruleSet; }
public void ActivityDTO_Validate_Executed_SetErrorsProperty() { //------------Setup for test-------------------------- var activityDTO = new ActivityDTO { FieldName = null }; var ruleSet = new RuleSet(); ruleSet.Add(new IsNullRule(() => activityDTO.FieldName)); //------------Execute Test--------------------------- activityDTO.Validate("FieldName", ruleSet); //------------Assert Results------------------------- Assert.AreEqual(1, activityDTO.Errors.Count); }
public void ActivityDTO_Validate_GivenRules_HasPassingRuleReturnTrue() { //------------Setup for test-------------------------- var activityDTO = new ActivityDTO { FieldName = "FeildName" }; var ruleSet = new RuleSet(); ruleSet.Add(new IsNullRule(() => activityDTO.FieldName)); //------------Execute Test--------------------------- bool isValid = activityDTO.Validate("FieldName", ruleSet); //------------Assert Results------------------------- Assert.IsTrue(isValid); }
public override IRuleSet GetRuleSet(string propertyName, string datalist) { RuleSet ruleSet = new RuleSet(); if (IsEmpty()) { return ruleSet; } switch (propertyName) { case "SearchType": if (SearchType == "Starts With" || SearchType == "Ends With" || SearchType == "Doesn't Start With" || SearchType == "Doesn't End With") { ruleSet.Add(new IsStringEmptyRule(() => SearchType)); ruleSet.Add(new IsValidExpressionRule(() => SearchType, datalist, "1")); } break; case "From": if (SearchType == "Is Between" || SearchType == "Is Not Between") { ruleSet.Add(new IsStringEmptyRule(() => From)); ruleSet.Add(new IsValidExpressionRule(() => From, datalist, "1")); } break; case "To": if (SearchType == "Is Between" || SearchType == "Is Not Between") { ruleSet.Add(new IsStringEmptyRule(() => To)); ruleSet.Add(new IsValidExpressionRule(() => To, datalist, "1")); } break; case "SearchCriteria": ruleSet.Add(new IsValidExpressionRule(() => SearchCriteria, datalist, "1")); break; } return ruleSet; }
void ValidateUserNameAndPassword(string userNameValue, string userNameLabel, Action onUserNameError, string passwordValue, string passwordLabel, Action onPasswordError) { var errors = new List<IActionableErrorInfo>(); var credentialUserRuleSet = new RuleSet(); var dataListViewModel = DataListSingleton.ActiveDataList; if(dataListViewModel != null) { var isValidExpressionRule = new IsValidExpressionRule(() => userNameValue, dataListViewModel.Resource.DataList); credentialUserRuleSet.Add(isValidExpressionRule); errors.AddRange(credentialUserRuleSet.ValidateRules(userNameLabel, onUserNameError)); var credentialPasswordRuleSet = new RuleSet(); isValidExpressionRule = new IsValidExpressionRule(() => passwordValue, dataListViewModel.Resource.DataList); credentialPasswordRuleSet.Add(isValidExpressionRule); errors.AddRange(credentialPasswordRuleSet.ValidateRules(passwordLabel, onPasswordError)); } if(errors.Count == 0) { var isStringEmptyOrWhiteSpaceRuleUserName = new IsStringEmptyOrWhiteSpaceRule(() => userNameValue) { LabelText = userNameLabel, DoError = onUserNameError }; var userNameBlankError = isStringEmptyOrWhiteSpaceRuleUserName.Check(); var isStringEmptyOrWhiteSpaceRulePassword = new IsStringEmptyOrWhiteSpaceRule(() => passwordValue) { LabelText = passwordLabel, DoError = onPasswordError }; var passwordBlankError = isStringEmptyOrWhiteSpaceRulePassword.Check(); if (userNameBlankError == null && passwordBlankError != null) { errors.Add(passwordBlankError); } else { if (passwordBlankError == null && userNameBlankError != null) { errors.Add(userNameBlankError); } } } UpdateErrors(errors); }
public override IRuleSet GetRuleSet(string propertyName, string datalist) { RuleSet ruleSet = new RuleSet(); if (String.IsNullOrEmpty( SourceName)) { return ruleSet; } if(propertyName == "SourceName") { ruleSet.Add(new IsValidJsonCreateMappingSourceExpression(() => SourceName)); } if(propertyName == "DestinationName") { ruleSet.Add(new IsStringEmptyOrWhiteSpaceRule(()=>DestinationName)); ruleSet.Add(new ShouldNotBeVariableRule(()=>DestinationName)); } return ruleSet; }