Пример #1
0
        /// <inheritdoc/>
        public RequestValidationResult Validate()
        {
            RequestValidationResult result = new RequestValidationResult();

            // Validate areas
            if (this.Areas.Count > 0)
            {
                // Validate individual areas
                foreach (Area area in this.Areas)
                {
                    // Use Area.Validate()
                    result.Combine(area.Validate());
                }
            }
            else
            {
                result.Fail(
                    RequestValidationIssue.InputEmpty,
                    nameof(this.Areas),
                    ValidationMessages.EmptyAreas
                    );
            }

            // Validate message
            if (String.IsNullOrEmpty(this.UserMessage))
            {
                result.Fail(
                    RequestValidationIssue.InputEmpty,
                    nameof(this.UserMessage),
                    ValidationMessages.EmptyMessage
                    );
            }

            return(result);
        }
Пример #2
0
        /// <inheritdoc/>
        public RequestValidationResult Validate()
        {
            RequestValidationResult result = new RequestValidationResult();

            // Validate provided NarrowcastArea
            if (this.Area != null)
            {
                // Use NarrowcastArea.Validate()
                result.Combine(this.Area.Validate());
            }
            else
            {
                result.Fail(
                    RequestValidationIssue.InputEmpty,
                    nameof(this.Area),
                    ValidationMessages.EmptyAreas
                    );
            }

            // Validate message
            if (String.IsNullOrEmpty(this.UserMessage))
            {
                result.Fail(
                    RequestValidationIssue.InputEmpty,
                    nameof(this.UserMessage),
                    ValidationMessages.EmptyMessage
                    );
            }

            return(result);
        }
Пример #3
0
        /// <inheritdoc/>
        public RequestValidationResult Validate()
        {
            RequestValidationResult result = new RequestValidationResult();

            // Must contain at least one of either BluetoothSeeds or AreaMatches
            if (this.AreaMatches.Count == 0 && this.BluetoothMatches.Count == 0)
            {
                result.Fail(
                    RequestValidationIssue.InputEmpty,
                    RequestValidationProperty.Multiple,
                    ValidationMessages.EmptyMessage
                    );
            }
            if (this.AreaMatches.Count > 0)
            {
                // Validate individual area matches
                foreach (AreaMatch areaMatch in this.AreaMatches)
                {
                    // Use AreaMatch.Validate()
                    result.Combine(areaMatch.Validate());
                }
            }
            if (this.BluetoothMatches.Count > 0)
            {
                // Validate individual Bluetooth matches
                foreach (BluetoothMatch btMatch in this.BluetoothMatches)
                {
                    // User BluetoothMatch.Validate()
                    result.Combine(btMatch.Validate());
                }
            }

            return(result);
        }
Пример #4
0
        /// <inheritdoc/>
        public RequestValidationResult Validate()
        {
            RequestValidationResult result = new RequestValidationResult();

            // Validate location
            if (this.Location == null)
            {
                result.Fail(
                    RequestValidationIssue.InputNull,
                    nameof(this.Location),
                    ValidationMessages.NullLocation
                    );
            }
            else
            {
                // Validate using Coordinates.Validate()
                result.Combine(this.Location.Validate());
            }

            // Validate timestamps
            result.Combine(Validator.ValidateTimestamp(this.BeginTimestamp,
                                                       asOf: DateTimeOffset.UtcNow.AddDays(FUTURE_TIME_WINDOW_DAYS).ToUnixTimeMilliseconds(),
                                                       maxAgeDays: FUTURE_TIME_WINDOW_DAYS + PAST_TIME_WINDOW_DAYS,
                                                       parameterName: nameof(this.BeginTimestamp)));
            result.Combine(Validator.ValidateTimestamp(this.EndTimestamp,
                                                       asOf: DateTimeOffset.UtcNow.AddDays(FUTURE_TIME_WINDOW_DAYS).ToUnixTimeMilliseconds(),
                                                       maxAgeDays: FUTURE_TIME_WINDOW_DAYS + PAST_TIME_WINDOW_DAYS,
                                                       parameterName: nameof(this.EndTimestamp)));
            result.Combine(Validator.ValidateTimeRange(this.BeginTimestamp, this.EndTimestamp));

            return(result);
        }
Пример #5
0
        /// <inheritdoc/>
        public RequestValidationResult Validate()
        {
            RequestValidationResult result = new RequestValidationResult();

            // Validate location
            if (this.Location == null)
            {
                result.Fail(
                    RequestValidationIssue.InputNull,
                    nameof(this.Location),
                    ValidationMessages.NullLocation
                    );
            }
            else
            {
                // Validate using Coordinates.Validate()
                result.Combine(this.Location.Validate());
            }

            // Validate timestamps
            result.Combine(Validator.ValidateTimestamp(this.BeginTimestamp, parameterName: nameof(this.BeginTimestamp)));
            result.Combine(Validator.ValidateTimestamp(this.EndTimestamp, parameterName: nameof(this.EndTimestamp)));
            result.Combine(Validator.ValidateTimeRange(this.BeginTimestamp, this.EndTimestamp));

            return(result);
        }
Пример #6
0
        /// <inheritdoc/>
        public RequestValidationResult Validate()
        {
            RequestValidationResult result = new RequestValidationResult();

            // Only validate if collection contains message information
            if (this.Seeds == null || this.Seeds.Count == 0)
            {
                result.Fail(
                    RequestValidationIssue.InputEmpty,
                    nameof(this.Seeds),
                    ValidationMessages.EmptySeeds
                    );
            }
            else
            {
                // Validate each seed
                foreach (BlueToothSeed seed in this.Seeds)
                {
                    // Use BlueToothSeed.Validate()
                    result.Combine(seed.Validate());
                }
            }

            // Validate Region
            if (this.Region == null)
            {
                result.Fail(
                    RequestValidationIssue.InputNull,
                    nameof(this.Region),
                    ValidationMessages.NullRegion
                    );
            }
            else
            {
                // Use Region.Validate()
                result.Combine(this.Region.Validate());
            }

            return(result);
        }
Пример #7
0
        /// <inheritdoc/>
        public RequestValidationResult Validate()
        {
            RequestValidationResult result = new RequestValidationResult();

            // Check if lat/lng are in expected values
            result.Combine(Validator.ValidateLatitude(this.LatitudePrefix, nameof(this.LatitudePrefix)));
            result.Combine(Validator.ValidateLongitude(this.LongitudePrefix, nameof(this.LongitudePrefix)));

            // Validate precision
            if (this.Precision < MIN_PRECISION || this.Precision > MAX_PRECISION)
            {
                result.Fail(
                    RequestValidationIssue.InputInvalid,
                    nameof(this.Precision),
                    ValidationMessages.InvalidPrecision,
                    this.Precision.ToString(),
                    MIN_PRECISION.ToString(),
                    MAX_PRECISION.ToString()
                    );
            }

            return(result);
        }
Пример #8
0
        /// <inheritdoc/>
        public RequestValidationResult Validate()
        {
            RequestValidationResult result = new RequestValidationResult();

            // Validate timestamp
            result.Combine(Validator.ValidateTimestamp(this.LastQueryTime, nameof(this.LastQueryTime)));

            // Validate region
            if (this.Region == null)
            {
                result.Fail(
                    RequestValidationIssue.InputNull,
                    nameof(this.Region),
                    ValidationMessages.NullRegion
                    );
            }
            else
            {
                // Use Region.Validate()
                result.Combine(this.Region.Validate());
            }

            return(result);
        }
Пример #9
0
        /// <inheritdoc/>
        public RequestValidationResult Validate()
        {
            RequestValidationResult result = new RequestValidationResult();

            // Must contain at least one of either BluetoothSeeds or NarrowcastMessages
            if (this.BluetoothSeeds.Count == 0 && this.Narrowcasts.Count == 0)
            {
                result.Fail(
                    RequestValidationIssue.InputEmpty,
                    RequestValidationProperty.Multiple,
                    ValidationMessages.EmptyMessage
                    );
            }

            // Validate individual messages
            if (this.BluetoothSeeds.Count > 0)
            {
                // Validate individual Bluetooth matches
                foreach (BluetoothSeedMessage seed in this.BluetoothSeeds)
                {
                    // Use BluetoothSeed.Validate()
                    result.Combine(seed.Validate());
                }
            }
            if (this.Narrowcasts.Count > 0)
            {
                // Validate individual area matches
                foreach (NarrowcastMessage message in this.Narrowcasts)
                {
                    // Use NarrowcastMessage.Validate()
                    result.Combine(message.Validate());
                }
            }

            return(result);
        }