public static void Validate(this ArtesianSearchFilter artesianSearchFilter)
        {
            var validSorts = @"^(MarketDataId|ProviderName|MarketDataName|OriginalGranularity|Type|OriginalTimezone|Created|LastUpdated)( (asc|desc))?$";

            if (artesianSearchFilter.Sorts != null)
            {
                foreach (string element in artesianSearchFilter.Sorts)
                {
                    if (element.Equals(validSorts))
                    {
                        throw new ArgumentException("Invalid search params");
                    }
                }
            }

            if (artesianSearchFilter.PageSize < 0)
            {
                throw new ArgumentException("Page size is less than 0");
            }

            if (artesianSearchFilter.Page < 0)
            {
                throw new ArgumentException("Page is less than 0");
            }

            if (artesianSearchFilter.Filters != null)
            {
                foreach (KeyValuePair <string, string[]> element in artesianSearchFilter.Filters)
                {
                    ArtesianUtils.IsValidString(element.Key, 3, 50);

                    if (element.Value != null)
                    {
                        if (element.Key != "MarketDataName")
                        {
                            foreach (string value in element.Value)
                            {
                                ArtesianUtils.IsValidString(value, 1, 50);
                            }
                        }
                        else if (element.Key == "MarketDataName")
                        {
                            foreach (string value in element.Value)
                            {
                                ArtesianUtils.IsValidString(value, 1, 250);
                            }
                        }
                    }
                }
            }
        }
 public static void Validate(this MarketDataIdentifier marketDataIdentifier)
 {
     ArtesianUtils.IsValidProvider(marketDataIdentifier.Provider, 1, 50);
     ArtesianUtils.IsValidMarketDataName(marketDataIdentifier.Name, 1, 250);
 }
Exemplo n.º 3
0
        public static void Validate(this Operations operations)
        {
            foreach (var id in operations.IDS)
            {
                if (id == null)
                {
                    throw new ArgumentException("Operations: any single ID must be valorized");
                }
                else
                {
                    if (String.IsNullOrWhiteSpace(id.ETag))
                    {
                        throw new ArgumentException("Operations: any single ETAG must be valorized");
                    }
                }
            }

            foreach (var op in operations.OperationList)
            {
                if (op == null)
                {
                    throw new ArgumentException("Operations: any single operation must be valorized");
                }
                else
                {
                    if (op.Params == null)
                    {
                        throw new ArgumentException("Operations: any single Params in operationList must be valorized");
                    }

                    switch (op.Type)
                    {
                    case OperationType.EnableTag:
                    {
                        var p = op.Params as OperationEnableDisableTag;

                        if (!p.TagKey.IsValidTagKey())
                        {
                            throw new ArgumentException("Operations: any single Params TagKey must have specific values");
                        }

                        ArtesianUtils.IsValidString(p.TagKey, 3, 50);

                        ArtesianUtils.IsValidString(p.TagValue, 1, 50);

                        break;
                    }

                    case OperationType.DisableTag:
                    {
                        var p = op.Params as OperationEnableDisableTag;

                        if (!p.TagKey.IsValidTagKey())
                        {
                            throw new ArgumentException("Operations: any single Params TagKey must have specific values");
                        }

                        ArtesianUtils.IsValidString(p.TagKey, 3, 50);

                        ArtesianUtils.IsValidString(p.TagValue, 1, 50);

                        break;
                    }

                    case OperationType.UpdateTimeTransformID:
                    {
                        var p = op.Params as OperationUpdateTimeTransform;

                        break;
                    }

                    case OperationType.UpdateAggregationRule:
                    {
                        var p = op.Params as OperationUpdateAggregationRule;

                        break;
                    }

                    case OperationType.UpdateOriginalTimeZone:
                    {
                        if (op.Params is OperationUpdateOriginalTimeZone p)
                        {
                            if (!String.IsNullOrWhiteSpace(p.Value) && DateTimeZoneProviders.Tzdb.GetZoneOrNull(p.Value) == null)
                            {
                                throw new ArgumentException("Operations: any single Params Value must be in IANA database if valorized");
                            }
                        }
                        else
                        {
                            throw new InvalidOperationException("Operations: Data cannot be used as OperationUpdateOriginalTimeZone");
                        }

                        break;
                    }

                    case OperationType.UpdateProviderDescription:
                    {
                        var p = op.Params as OperationUpdateProviderDescription;

                        break;
                    }

                    default:
                        throw new NotSupportedException("Operations: The Operation Type is not supported");
                    }
                }
            }
        }