public bool Validate(TypeMoniker parameterType, FacetMoniker moniker) { var sourceType = ExtraDataType == null ? parameterType.AssemblyQualifiedName : ExtraDataType.AssemblyQualifiedName; var data = moniker[sourceType, Key]; if (data == null) { return(AllowMissing); } if ((RegularExpression == null) == (ValidValues == null)) { throw new InvalidOperationException("One and only one of ValidValues or RegularExpression must be non-null"); } if (ValidValues != null) { return(ValidValues.Contains(data, StringComparer.CurrentCultureIgnoreCase)); } return(Regex.IsMatch(data, RegularExpression, RegexOptions.IgnoreCase)); }
public override void Validate(string value) { base.Validate(value); int parsedValue; if (!Int32.TryParse(value, out parsedValue)) { throw new FormatException("Value cannot be parsed as an integer."); } if (AlwaysAllowZero && parsedValue == 0) { return; } if (MinValue != int.MinValue && parsedValue < MinValue) { throw new FormatException(String.Format("Value is too low ({0}); expected at least {1}.", parsedValue, MinValue)); } if (MaxValue != int.MaxValue && parsedValue > MaxValue) { throw new FormatException(String.Format("Value is too high ({0}); expected at most {1}.", parsedValue, MaxValue)); } if (MultipleOf != 0 && (parsedValue % MultipleOf != 0)) { throw new FormatException(String.Format("Value ({0}) is not a multiple of {1}.", parsedValue, MultipleOf)); } if (PowerOfTwo) { bool found = false; for (int i = 0; i < 31; i++) { if (parsedValue == (1 << i)) { found = true; break; } } if (!found && parsedValue != 0) { throw new FormatException(String.Format("Value ({0}) is not a power of two.", parsedValue)); } } if (ValidValues != null) { if (!ValidValues.Any(t => parsedValue == t)) { throw new FormatException(String.Format("Value ({0}) is not on the list of valid values.", parsedValue)); } } if (InvalidValues != null) { if (!InvalidValues.All(t => parsedValue != t)) { throw new FormatException(String.Format("Value ({0}) is on the list of invalid values.", parsedValue)); } } }
public void ValidGetAclActionListTests(Params param, ValidValues value) { var request = new Dictionary <string, string>(); if (value == ValidValues.MissingParam) { request.Remove(param.ToString()); } else { ValidValuesMapper[value](param.ToString(), request); } var defaultManager = new DefaultManager(); try { var response = defaultManager.Send <AclActionListResponse.ResponseItem>(Endpoint, request, HttpMethod.GET); PrAssert.That(response, PrIs.SuccessfulResponse().And.HttpCode((int)System.Net.HttpStatusCode.OK)); var actions = response.Result.Actions["0"]["117"][0]; PrAssert.Equals(actions.ActionList.Category, "Mail"); PrAssert.Equals(actions.ActionList.Target, "General"); PrAssert.Equals(actions.ActionList.Type, "OpenMailbox"); PrAssert.Equals(actions.ActionList.SubType, ""); PrAssert.Equals(actions.ActionList.customActionId, ""); PrAssert.Equals(actions.Label.En_Us.Value, "Open Mailbox"); PrAssert.Equals(actions.Label.Ja.Value, "メールボックスを開く"); } catch (System.Exception) { throw; } }
public Dictionary <string, Location> GetCompanyLocations(int subscriberId, bool filteredByZip = true) { var locationsByCustomerNumber = new Dictionary <string, Location>(); foreach (var manifestLegs in _dictionary.Values) { var legs = manifestLegs.AllLegs; foreach (var l in legs) { if (filteredByZip && !ValidValues.IsValidZipCode(l.CompanyZipInt)) { continue; } if (!locationsByCustomerNumber.ContainsKey(l.CustomerNumber)) { var loc = new Location() { SubscriberId = subscriberId, DisplayName = l.CompanyName, LegacyId = l.CustomerNumber, StreetAddress = l.CompanyAddress1, City = l.CompanyCity, State = l.CompanyState, Zip = l.CompanyZip }; locationsByCustomerNumber.Add(l.CustomerNumber, loc); } } } return(locationsByCustomerNumber); }
public Track2ValidatorTests() : base(OpenIso8583Net.FieldValidator.FieldValidators.Track2) { // TODO add more invalid test cases for things like bad month and bad service restriction code ValidValues.Add("58889290122738116===13216843253657432"); ValidValues.Add("58889290122738116=991250113216843253657432"); ValidValues.Add("58889290122738116==50113216843253657432"); ValidValues.Add("58889290122738116=9912=13216843253657432"); ValidValues.Add("58889290122738116DDD13216843253657432"); ValidValues.Add("58889290122738116D991250113216843253657432"); ValidValues.Add("58889290122738116DD50113216843253657432"); ValidValues.Add("58889290122738116D9912D13216843253657432"); InvalidValues.Add("D0002135"); InvalidValues.Add("C000002135"); InvalidValues.Add("D000002135"); InvalidValues.Add("abcdef"); InvalidValues.Add("123468dfc"); InvalidValues.Add("123456"); InvalidValues.Add(" "); InvalidValues.Add("123abcdefg"); InvalidValues.Add("./'[]"); InvalidValues.Add("\t"); InvalidValues.Add("\n"); }
private PropertySetResult PopulateNumberPropertyLite() { if (ValidValues != null && ValidValues.Any()) { return(new PropertySetResult(InstancePropertyTypeId, ErrorCodes.InvalidArtifactProperty, "Property type is now number property. Property change action is currently invalid.")); } if (String.IsNullOrEmpty(PropertyValue)) { PropertyLiteValue = new PropertyLite() { PropertyTypeId = InstancePropertyTypeId, NumberValue = null }; } else { decimal value; if ( !Decimal.TryParse(PropertyValue, NumberStyles.Number, CultureInfo.InvariantCulture, out value)) { return(new PropertySetResult(InstancePropertyTypeId, ErrorCodes.InvalidArtifactProperty, "Property type is now number property. Property change action is currently invalid.")); } PropertyLiteValue = new PropertyLite() { PropertyTypeId = InstancePropertyTypeId, NumberValue = value }; } return(null); }
protected override void ValidValues_ItemsAdded(object sender, CollectionItemsChangedEventArgs <T> e) { if (Value == null) { Value = ValidValues.First(); } }
protected override void ValidValues_CollectionReset(object sender, CollectionItemsChangedEventArgs <T> e) { if ((Value != null) && !ValidValues.Contains(Value)) { Value = ValidValues.FirstOrDefault(); } }
public void EliminateValue(int value) { if (!ValueValid(value)) { throw new ArgumentException($"Trying to eliminate an invalid value: {value}. " + $"The valid value range is [{ValidValues.Min()};{ValidValues.Max()}]."); } EliminatedValues.Add(value); }
public AlphaNumericPrintableValidatorTests() : base(OpenIso8583Net.FieldValidator.FieldValidators.AlphaNumericPrintable) { ValidValues.Add("ab23cdef"); ValidValues.Add("ABC23DEF"); ValidValues.Add("adsf7346,."); ValidValues.Add("1324234"); ValidValues.Add("ab23c def"); ValidValues.Add(".,?#'"); }
public int?SetCellValue(int?value) { if (value != null && !ValueValid(value.Value)) { throw new ArgumentException($"Trying to set to an invalid value: {value}. " + $"The valid value range is [{ValidValues.Min()};{ValidValues.Max()}]."); } _currentValue = value; return(_currentValue); }
public AlphaValidatorTests() : base(OpenIso8583Net.FieldValidator.FieldValidators.Alpha) { ValidValues.Add("abcdef"); ValidValues.Add("ABCDEF"); InvalidValues.Add("adsf234"); InvalidValues.Add("1324234"); InvalidValues.Add(".,?#'"); InvalidValues.Add(" "); InvalidValues.Add("adsf fasdf"); }
private void InitializeStruct() { validValues = new ValidValues(); validValues.minT = Convert.ToInt64(ConfigurationManager.AppSettings["minT"]); validValues.maxT = Convert.ToInt64(ConfigurationManager.AppSettings["maxT"]); validValues.minN = Convert.ToInt64(ConfigurationManager.AppSettings["minN"]); validValues.maxN = Convert.ToInt64(ConfigurationManager.AppSettings["maxN"]); validValues.minM = Convert.ToInt64(ConfigurationManager.AppSettings["minM"]); validValues.maxM = Convert.ToInt64(ConfigurationManager.AppSettings["maxM"]); validValues.minW = Convert.ToInt64(ConfigurationManager.AppSettings["minW"]); validValues.maxW = Convert.ToInt64(ConfigurationManager.AppSettings["maxW"]); }
public AlphaOrNumericValidatorTests() : base(OpenIso8583Net.FieldValidator.FieldValidators.AlphaOrNumeric) { ValidValues.Add("1234567890"); ValidValues.Add("ABCdef"); InvalidValues.Add("1234a"); InvalidValues.Add("1324.234"); InvalidValues.Add("abcdef1"); InvalidValues.Add("ZYX "); InvalidValues.Add(".,?#'"); }
public NoneValidatorTests() : base(OpenIso8583Net.FieldValidator.FieldValidators.None) { ValidValues.Add("0123456789"); ValidValues.Add("ABCDEF"); ValidValues.Add("abcdef"); ValidValues.Add("123468dfc"); ValidValues.Add(" "); ValidValues.Add("123abcdefg"); ValidValues.Add("./'[]"); ValidValues.Add("\t"); ValidValues.Add("\n"); }
public override int GetHashCode() { unchecked { int hashCode = base.GetHashCode(); hashCode = (hashCode * 397) ^ (PropertyName != null ? PropertyName.GetHashCode() : 0); hashCode = (hashCode * 397) ^ PropertyId.GetHashCode(); hashCode = (hashCode * 397) ^ (PropertyValue != null ? PropertyValue.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (ValidValues != null ? ValidValues.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (UsersGroups != null ? UsersGroups.GetHashCode() : 0); return(hashCode); } }
public override bool TryGetTokenFromInput(ITextCursor textCursor, out string token) { var match = false; token = null; if (ValidValues != null && ValidValues.Length > 0) { string matchText = null; var queryText = string.Empty; while (string.IsNullOrEmpty(matchText) && ValidValues.Any(v => v.Length >= queryText.Length)) { var tokenPeek = textCursor.Next(); if (string.IsNullOrWhiteSpace(tokenPeek)) { break; } queryText = textCursor.RightToLeftParsing ? $"{tokenPeek} {queryText}" : $"{queryText} {tokenPeek}"; matchText = TryGetMatchText(ValidValues, queryText.Trim()); } if (!string.IsNullOrEmpty(matchText)) { token = matchText; match = true; } } else { var queryText = textCursor.All(); if (!string.IsNullOrEmpty(queryText)) { token = queryText; match = true; } } return(match); }
public override string ToString() { StringBuilder message = new StringBuilder(); if (!String.IsNullOrEmpty(TableName)) { message.AppendLine($"Table: {TableName}"); } if (QueryLineNumber > 0) { message.AppendLine($"Line: {QueryLineNumber}"); } if (!String.IsNullOrEmpty(Usage)) { message.AppendLine($"Usage: {Usage}"); } if (!String.IsNullOrEmpty(ErrorMessage)) { message.AppendLine(ErrorMessage); } else { if (String.IsNullOrEmpty(InvalidValueCategory)) { message.AppendLine($"Value \"{InvalidValue}\" found when no more arguments were expected."); } else if (String.IsNullOrEmpty(InvalidValue)) { message.AppendLine($"No argument found when {InvalidValueCategory} was required."); } else { message.AppendLine($"\"{InvalidValue}\" was not a valid {InvalidValueCategory}."); } } if (ValidValues != null) { message.AppendLine("Valid Options:"); foreach (string value in ValidValues.OrderBy((s) => s)) { message.AppendLine(value); } } return(message.ToString()); }
public string CheckUserInput(string input) { input = input.ToLower(); if (!ValidValues.Contains(input)) { input = "Error"; } else { if (input.Length > 1 && input != "spock") { input = input[0].ToString(); } } return(input); }
protected virtual PropertySetResult PopulatePropertyLite(WorkflowPropertyType propertyType) { switch (propertyType?.PrimitiveType) { case PropertyPrimitiveType.Text: PropertyLiteValue = new PropertyLite() { PropertyTypeId = InstancePropertyTypeId, TextOrChoiceValue = PropertyValue }; break; case PropertyPrimitiveType.Number: return(PopulateNumberPropertyLite()); case PropertyPrimitiveType.Date: return(PopulateDatePropertyLite()); case PropertyPrimitiveType.Choice: PropertyLiteValue = new PropertyLite { PropertyTypeId = InstancePropertyTypeId, }; if (!ValidValues.Any() && !propertyType.Validate.GetValueOrDefault(false)) { PropertyLiteValue.TextOrChoiceValue = PropertyValue; } else { PropertyLiteValue.ChoiceIds.AddRange(ValidValues); } break; case PropertyPrimitiveType.User: return(new PropertySetResult(InstancePropertyTypeId, ErrorCodes.InvalidArtifactProperty, "Property type is now user, but does not contain user and group change actions")); default: PropertyLiteValue = new PropertyLite() { PropertyTypeId = InstancePropertyTypeId }; break; } return(null); }
public Rev87AmountValidatorTests() : base(OpenIso8583Net.FieldValidator.FieldValidators.Rev87AmountValidator) { ValidValues.Add("C0002135"); ValidValues.Add("D0002135"); ValidValues.Add("C000002135"); ValidValues.Add("D000002135"); InvalidValues.Add("ABCDEF"); InvalidValues.Add("abcdef"); InvalidValues.Add("123468dfc"); InvalidValues.Add("123456"); InvalidValues.Add(" "); InvalidValues.Add("123abcdefg"); InvalidValues.Add("./'[]"); InvalidValues.Add("\t"); InvalidValues.Add("\n"); }
public void LoadValidValues(Report rpt) { _validValues = new List <ParameterValue>(); if (_validValuesDS != null) { DataSet ds = rpt.DataSets[_validValuesDS.DataSetName]; if (ds == null) { throw new Exception("Invalid data set " + _validValuesDS.DataSetName + " in ReportParameter"); } if (ds.Fields[_validValuesDS.ValueField] == null) { throw new Exception("Invalid value field " + _validValuesDS.ValueField + " in ReportParameter"); } if (_validValuesDS.LableField != null && ds.Fields[_validValuesDS.LableField] == null) { throw new Exception("Invalid label field " + _validValuesDS.LableField + " in ReportParameter"); } //System.Data.DataSet dsTemp = new System.Data.DataSet(); //ds.Initialize(dsTemp); ds.Reset(); Rdl.Runtime.Context context = new Rdl.Runtime.Context(null, ds, null, null, null); ValidValues.Clear(); while (context.CurrentRow != null) { string value = context.CurrentRow[_validValuesDS.ValueField].ToString(); string label = string.Empty; if (_validValuesDS.LableField != null) { label = context.CurrentRow[_validValuesDS.LableField].ToString(); } ParameterValue pv = new ParameterValue(value, label); if (!_validValues.Contains(pv)) { _validValues.Add(pv); } context.MoveNext(); } } }
private PropertySetResult PopulateDatePropertyLite() { // was Choice property if (ValidValues != null && ValidValues.Any()) { return(new PropertySetResult(InstancePropertyTypeId, ErrorCodes.InvalidArtifactProperty, "Property type is now date property. Property change action is currently invalid.")); } // is null if (string.IsNullOrEmpty(PropertyValue)) { PropertyLiteValue = new PropertyLite { PropertyTypeId = InstancePropertyTypeId, DateValue = null }; return(null); } DateTime date; try { date = PropertyHelper.ParseDateValue(PropertyValue, new TimeProvider()); } catch (Exception ex) { // invalid date format return(new PropertySetResult(InstancePropertyTypeId, ErrorCodes.InvalidArtifactProperty, $"Property type is now date property. Property change action is currently invalid. {ex.Message}")); } // valid date format PropertyLiteValue = new PropertyLite { PropertyTypeId = InstancePropertyTypeId, DateValue = date }; return(null); }
public override bool TryGetTokenFromContext(IRequestContext context, out string token) { var match = false; token = null; var variableName = Name; if (!string.IsNullOrWhiteSpace(ContextVariableName)) { variableName = ContextVariableName; } var objTokenValue = context.GetVariable(variableName); if (objTokenValue != null) { var tokenValue = (string)objTokenValue; if (ValidValues != null && ValidValues.Length > 0) { if ( ValidValues.Any( w => w.ToString().Equals(tokenValue.ToString(), StringComparison.OrdinalIgnoreCase))) { token = tokenValue; match = true; } } else { token = tokenValue; match = true; } } return(match); }
/// <summary> /// Returns a clone of this instance. /// </summary> /// <returns>Cloned copy of this instance.</returns> public Field Clone() { return(new Field { AllowNotFoundValid = AllowNotFoundValid, DependentField = DependentField, DependentValues = DependentValues.ToList(), DynamicLength = DynamicLength, ExclusiveDependency = ExclusiveDependency, Length = Length, Name = Name, OptionValues = OptionValues.ToList(), ParseUntil = ParseUntil, RejectionCode = RejectionCode, Repetitions = Repetitions, Skip = Skip, SkipUntil = SkipUntil, StaticRepetitions = StaticRepetitions, Type = Type, ValidValues = ValidValues.ToList() }); }
public ChoiceSetting(string name, string title, object defaultValue = null, ChoiceSettingValue[] values = null, bool multiple = false) : base(name, title, null) { if (values == null) { values = new ChoiceSettingValue[0]; } if (defaultValue != null) { if (defaultValue != null) { base.DefaultValue = defaultValue; } else { base.DefaultValue = null; } } foreach (ChoiceSettingValue value in values) { ValidValues.Add(value); } MultipleSelect = multiple; }
public override bool TryGetTokenFromInput(ITextCursor textCursor, out string token) { var match = false; token = null; if (ValidValues != null && ValidValues.Length > 0) { string matchText = null; var queryText = string.Empty; while (true) { var tokenPeek = textCursor.Peek(); if (string.IsNullOrWhiteSpace(tokenPeek)) { break; } if (textCursor.RightToLeftParsing) { queryText = $"{tokenPeek} {queryText}"; } else { queryText = $"{queryText} {tokenPeek}"; } queryText = queryText.Trim(); string[] matchTexts; if (textCursor.RightToLeftParsing) { matchTexts = ValidValues .Where(t => t.EndsWith(queryText, StringComparison.InvariantCultureIgnoreCase)) .OrderByDescending(t => t.Length) .ToArray(); } else { matchTexts = ValidValues .Where(t => t.StartsWith(queryText, StringComparison.InvariantCultureIgnoreCase)) .OrderByDescending(t => t.Length) .ToArray(); } if (matchTexts.Length >= 1) { // Avança o cursor textCursor.Next(); if (matchTexts.Any(t => t.Equals(queryText, StringComparison.InvariantCultureIgnoreCase))) { matchText = queryText; } } else { break; } } if (!string.IsNullOrEmpty(matchText)) { token = matchText; match = true; } } else { var queryText = textCursor.All(); if (!string.IsNullOrEmpty(queryText)) { token = queryText; match = true; } } return(match); }
public bool ValueValid(int value) => ValidValues.Contains(value);
public ValidValuesTests() { _att = new ValidValues("CALL", "PUT"); }
protected bool Equals(CLIFlagAttribute other) { return(base.Equals(other) && Flag == other.Flag && Help == other.Help && Category == other.Category && Visitor == other.Visitor && Hidden == other.Hidden && VisitorAssembly == other.VisitorAssembly && IsRequired == other.IsRequired && Positional == other.Positional && Default?.Equals(other.Default) == true && ValidValues?.Equals(other.ValidValues) == true && Aliases?.Equals(other.Aliases) == true); }