/// <inheritdoc />
 public void Validate(string errorLocation, string propertyPath = "")
 {
     FulcrumValidate.IsNotNullOrWhiteSpace(Originator, nameof(Originator), errorLocation);
     FulcrumValidate.IsNotNull(UtcDateTimeOffset, nameof(UtcDateTimeOffset), errorLocation);
     FulcrumValidate.IsNotDefaultValue(UtcDateTimeOffset, nameof(UtcDateTimeOffset), errorLocation);
     FulcrumValidate.IsNotNull(SeverityLevel, nameof(SeverityLevel), errorLocation);
 }
 /// <inheritdoc />
 public void Validate(string errorLocation, string propertyPath = "")
 {
     // Validate the fields of this object
     FulcrumValidate.IsNotNullOrWhiteSpace(Name, $"{nameof(Name)}", errorLocation);
     // Validate the fields of this object
     FulcrumValidate.IsNotNullOrWhiteSpace(MembershipNumber, $"{nameof(MembershipNumber)}", errorLocation);
 }
 /// <inheritdoc />
 public void Validate(string errorLocation, string propertyPath = "")
 {
     FulcrumValidate.IsNotDefaultValue(TimeStamp, nameof(TimeStamp), errorLocation);
     //FulcrumValidate.IsLessThanOrEqualTo(DateTimeOffset.Now, TimeStamp, nameof(TimeStamp), errorLocation);
     FulcrumValidate.IsNotDefaultValue(SeverityLevel, nameof(SeverityLevel), errorLocation);
     FulcrumValidate.IsNotNullOrWhiteSpace(Message, nameof(Message), errorLocation);
 }
 /// <inheritdoc />
 public void Validate(string errorLocation, string propertyPath = "")
 {
     if (Enabled)
     {
         FulcrumValidate.IsNotNull(ServiceConfiguration, nameof(ServiceConfiguration), errorLocation);
     }
 }
Exemple #5
0
 /// <inheritdoc />
 public void Validate(string errorLocation, string propertyPath = "")
 {
     if (Enabled)
     {
         FulcrumValidate.IsNotNull(RegexForFindingTenantInUrl, nameof(RegexForFindingTenantInUrl), errorLocation);
     }
 }
 /// <inheritdoc />
 public override void Validate(string errorLocation, string propertyPath = "")
 {
     base.Validate(errorLocation, propertyPath);
     FulcrumValidate.IsNotDefaultValue(LockId, nameof(LockId), errorLocation);
     FulcrumValidate.IsNotNull(TableName, nameof(TableName), errorLocation);
     FulcrumValidate.IsNotDefaultValue(LockedRecordId, nameof(LockedRecordId), errorLocation);
 }
 /// <inheritdoc />
 public virtual void Validate(string errorLocation, string propertyPath = "")
 {
     FulcrumValidate.IsNotNullOrWhiteSpace(PersonId, nameof(PersonId), errorLocation);
     FulcrumValidate.IsNotNullOrWhiteSpace(ConsentId, nameof(ConsentId), errorLocation);
     FulcrumValidate.IsNotNullOrWhiteSpace(ConsentName, nameof(ConsentName), errorLocation);
     FulcrumValidate.IsNotNullOrWhiteSpace(PersonName, nameof(PersonName), errorLocation);
 }
Exemple #8
0
 /// <inheritdoc />
 public void Validate(string errorLocation, string propertyPath = "")
 {
     FulcrumValidate.IsNotNull(Key, nameof(Key), errorLocation);
     FulcrumValidate.IsValidated(Key, propertyPath, nameof(Key), errorLocation);
     FulcrumValidate.IsNotNull(AssociatedKeys, nameof(AssociatedKeys), errorLocation);
     FulcrumValidate.IsValidated(AssociatedKeys, propertyPath, nameof(AssociatedKeys), errorLocation);
 }
 /// <inheritdoc />
 public override void Validate(string errorLocation, string propertyPath = "")
 {
     base.Validate(errorLocation, propertyPath);
     FulcrumValidate.IsNotNullOrWhiteSpace(Name, nameof(Name), errorLocation);
     FulcrumValidate.IsNotNullOrWhiteSpace(Id, nameof(Id), errorLocation);
     FulcrumValidate.IsNotNullOrWhiteSpace(Etag, nameof(Etag), errorLocation);
 }
 /// <inheritdoc />
 public void Validate(string errorLocation, string propertyPath = "")
 {
     FulcrumValidate.IsNotNullOrWhiteSpace(Organization, nameof(Organization), errorLocation);
     FulcrumValidate.IsNotNullOrWhiteSpace(Environment, nameof(Environment), errorLocation);
     FulcrumValidate.AreEqual(Organization.ToLower(), Organization, nameof(Organization), errorLocation);
     FulcrumValidate.AreEqual(Environment.ToLower(), Environment, nameof(Environment), errorLocation);
 }
 /// <inheritdoc />
 public void Validate(string errorLocation, string propertyPath = "")
 {
     FulcrumValidate.IsValidated(PageInfo, propertyPath, nameof(PageInfo), errorLocation);
     if (!FulcrumApplication.IsInProduction)
     {
         FulcrumValidate.AreEqual(PageInfo.Returned, Data.Count(), nameof(Data), $"Validation of {nameof(PageEnvelope<T>)} failed. The number of items in {nameof(Data)} ({Data.Count()}) must be the same as {nameof(PageInfo.Returned)} ({PageInfo.Returned}).");
     }
 }
Exemple #12
0
 /// <inheritdoc />
 public void Validate(string errorLocation, string propertyPath = "")
 {
     FulcrumValidate.IsNotNull(WaitingForRequestIds, nameof(WaitingForRequestIds), errorLocation);
     foreach (var waitingForRequestId in WaitingForRequestIds)
     {
         FulcrumValidate.IsNotNull(waitingForRequestId, nameof(WaitingForRequestIds), errorLocation);
     }
 }
Exemple #13
0
        /// <inheritdoc />
        public override void Validate(string errorLocaction, string propertyPath = "")
        {
            base.Validate(errorLocaction, propertyPath);
            var now = DateTimeOffset.Now;

            FulcrumValidate.IsTrue(RecordCreatedAt < now, errorLocaction, $"Expected {nameof(RecordCreatedAt)} ({RecordCreatedAt}) to have a value less than the current time ({now}).");
            FulcrumValidate.IsTrue(RecordUpdatedAt < now, errorLocaction, $"Expected {nameof(RecordUpdatedAt)} ({RecordUpdatedAt}) to have a value less than the current time ({now}).");
        }
 /// <inheritdoc />
 public void Validate(string errorLocation, string propertyPath = "")
 {
     FulcrumValidate.IsNotNullOrWhiteSpace(Name, nameof(Name), errorLocation);
     FulcrumValidate.AreNotEqual(RunTimeLevelEnum.None, RunTimeLevel, nameof(RunTimeLevel), errorLocation);
     FulcrumValidate.IsValidated(Tenant, propertyPath, nameof(Tenant), errorLocation);
     FulcrumValidate.IsNotNull(ThreadHandler, nameof(ThreadHandler), errorLocation);
     FulcrumValidate.IsNotNull(SynchronousFastLogger, nameof(SynchronousFastLogger), errorLocation);
     FulcrumValidate.IsNotNull(FallbackLogger, nameof(FallbackLogger), errorLocation);
 }
 public void Validate(string errorLocation, string propertyPath = "")
 {
     FulcrumValidate.IsNotNullOrWhiteSpace(Name, nameof(Name), errorLocation);
     if (Id != null || Etag != null)
     {
         FulcrumValidate.IsNotNullOrWhiteSpace(Id, nameof(Id), errorLocation);
         FulcrumValidate.IsNotNullOrWhiteSpace(Etag, nameof(Etag), errorLocation);
     }
 }
 /// <inheritdoc />
 public virtual void Validate(string errorLocaction, string propertyPath = "")
 {
     FulcrumValidate.IsGreaterThanOrEqualTo(0, Offset, nameof(Offset), errorLocaction);
     FulcrumValidate.IsGreaterThanOrEqualTo(0, Limit, nameof(Limit), errorLocaction);
     FulcrumValidate.IsGreaterThanOrEqualTo(0, Returned, nameof(Returned), errorLocaction);
     if (Total != null)
     {
         FulcrumValidate.IsGreaterThanOrEqualTo(0, Total.Value, nameof(Total), errorLocaction);
     }
 }
 /// <inheritdoc/>
 public override void Validate(string errorLocaction, string propertyPath = "")
 {
     FulcrumValidate.IsGreaterThan(0, Id, nameof(Id), errorLocaction);
     FulcrumValidate.IsNotNullOrWhiteSpace(Name, nameof(Name), errorLocaction);
     FulcrumValidate.IsTrue(Regex.IsMatch(Name, "^[a-zA-Z]+$"), errorLocaction, $"Property {nameof(Name)} must only consist of upper or lower case a-z.");
     FulcrumValidate.IsNotNullOrWhiteSpace(Category, nameof(Category), errorLocaction);
     FulcrumValidate.IsTrue(Regex.IsMatch(Category, "^[a-zA-Z]+$"), errorLocaction, $"Property {nameof(Category)} must only consist of upper or lower case a-z.");
     FulcrumValidate.IsGreaterThanOrEqualTo(0.0, Price, nameof(Price), errorLocaction);
     FulcrumValidate.IsNotDefaultValue(DateAdded, nameof(DateAdded), errorLocaction);
     FulcrumValidate.IsLessThanOrEqualTo(DateTimeOffset.Now, DateAdded, nameof(DateAdded), errorLocaction);
 }
 /// <inheritdoc/>
 public void Validate(string errorLocaction, string propertyPath = "")
 {
     FulcrumValidate.IsNotNullOrWhiteSpace(Id, nameof(Id), errorLocaction);
     FulcrumValidate.IsNotNullOrWhiteSpace(Name, nameof(Name), errorLocaction);
     FulcrumValidate.MatchesRegExp("^[a-zA-Z]+$", Name, nameof(Name), errorLocaction);
     FulcrumValidate.IsNotNullOrWhiteSpace(Category, nameof(Category), errorLocaction);
     FulcrumValidate.MatchesRegExp("^[a-zA-Z]+$", Category, nameof(Category), errorLocaction);
     FulcrumValidate.IsGreaterThanOrEqualTo(0.0, Price, nameof(Price), errorLocaction);
     FulcrumValidate.IsNotDefaultValue(DateAdded, nameof(DateAdded), errorLocaction);
     FulcrumValidate.IsLessThanOrEqualTo(DateTimeOffset.Now, DateAdded, nameof(DateAdded), errorLocaction);
 }
        /// <inheritdoc />
        public void Validate(string errorLocation, string propertyPath = "")
        {
            FulcrumValidate.IsNotNullOrWhiteSpace(Method, nameof(Method), errorLocation);
            FulcrumValidate.IsNotNullOrWhiteSpace(EncodedUrl, nameof(EncodedUrl), errorLocation);
            FulcrumValidate.IsTrue(IsValidUri(EncodedUrl), errorLocation, $"{propertyPath}.{nameof(EncodedUrl)} is not a valid URL.");
            FulcrumValidate.IsTrue(HttpMethodExists(), errorLocation, $"{Method} is not a valid HttpMethod");
            if (BodyAsString != null)
            {
                FulcrumValidate.IsTrue(JsonHelper.TryDeserializeObject(BodyAsString, out JToken _), errorLocation,
                                       $"{propertyPath}.{nameof(BodyAsString)} must be JSON.");
            }
            ValidateHeaders();

            bool HttpMethodExists()
            {
                var propertyInfo = typeof(System.Net.Http.HttpMethod).GetProperty(Method,
                                                                                  BindingFlags.IgnoreCase | BindingFlags.Static | BindingFlags.Public);

                return(propertyInfo != null);
            }

            bool IsValidUri(string url)
            {
                var result = Uri.TryCreate(url, UriKind.Absolute, out var uri) &&
                             (uri.Scheme == Uri.UriSchemeHttp || uri.Scheme == Uri.UriSchemeHttps);

                return(result);
            }

            void ValidateHeaders()
            {
                if (Headers != null && Headers.Any())
                {
                    var index = 0;
                    foreach (var header in Headers)
                    {
                        index++;
                        FulcrumValidate.IsNotNullOrWhiteSpace(header.Key, "ignore", errorLocation,
                                                              $"Header {index} in {propertyPath}.{nameof(Headers)} had an empty key.");
                        FulcrumValidate.IsTrue(!header.Key.StartsWith("Content-"), errorLocation,
                                               $"Header {header.Key} is not allowed, as it is a content header.");
                        FulcrumValidate.IsNotNullOrWhiteSpace(header.Value.ToString(), "ignore", errorLocation,
                                                              $"Header {header.Key} had an empty value.");
                        FulcrumValidate.IsTrue(header.Value.Any(), errorLocation,
                                               $"Header {header.Key} had no values.");
                        FulcrumValidate.IsTrue(!header.Value.Any(string.IsNullOrWhiteSpace), errorLocation,
                                               $"Header {header.Key} had an empty value.");
                    }
                }
            }
        }
        /// <inheritdoc />
        public void Validate(string errorLocation, string propertyPath = "")
        {
            if (Type != null)
            {
                FulcrumValidate.IsTrue(Type == "private" || Type == "public", null, $"{nameof(Type)} must have one of the values \"private\" and \"public\".");
            }
            FulcrumValidate.IsGreaterThanOrEqualTo(0, Created, nameof(Created), errorLocation);
            var now = DateTimeOffset.Now;

            if (StartInclusive != null)
            {
                FulcrumValidate.IsLessThanOrEqualTo(now, StartInclusive.Value, nameof(StartInclusive), errorLocation);
            }
            if (EndExlusive != null)
            {
                FulcrumValidate.IsLessThanOrEqualTo(now, EndExlusive.Value, nameof(EndExlusive), errorLocation);
            }
        }
 /// <inheritdoc />
 public void Validate(string errorLocation, string propertyPath = "")
 {
     FulcrumValidate.IsNotNullOrWhiteSpace(Etag, nameof(Etag), errorLocation);
 }
Exemple #22
0
 /// <inheritdoc />
 public void Validate(string errorLocation, string propertyPath = "")
 {
     FulcrumValidate.IsNotNullOrWhiteSpace(TableName, nameof(TableName), errorLocation);
     FulcrumValidate.IsNotNull(CustomColumnNames, nameof(CustomColumnNames), errorLocation);
     FulcrumValidate.IsNotNull(OrderBy, nameof(OrderBy), errorLocation);
 }
 public void Validate(string errorLocation, string propertyPath = "")
 {
     FulcrumValidate.IsNotNullOrWhiteSpace(Row1, nameof(Row1), errorLocation);
     FulcrumValidate.IsNotNullOrWhiteSpace(PostCode, nameof(PostCode), errorLocation);
     FulcrumValidate.IsNotNullOrWhiteSpace(Country, nameof(Country), errorLocation);
 }
 /// <inheritdoc />
 public virtual void Validate(string errorLocation, string propertyPath = "")
 {
     FulcrumValidate.IsNotNullOrWhiteSpace(Name, nameof(Name), errorLocation);
 }
Exemple #25
0
 /// <inheritdoc />
 public virtual void Validate(string errorLocation, string propertyPath = "")
 {
     FulcrumValidate.IsNotNullOrWhiteSpace(TechnicalMessage, nameof(TechnicalMessage), errorLocation);
     FulcrumValidate.IsNotNullOrWhiteSpace(Type, nameof(Type), errorLocation);
     FulcrumValidate.IsNotNullOrWhiteSpace(InstanceId, nameof(InstanceId), errorLocation);
 }
Exemple #26
0
 public void Validate(string errorLocation, string propertyPath = "")
 {
     FulcrumValidate.IsTrue(Value != TestItemBare.ValueToMakeValidationFail, errorLocation,
                            $"The value must not be {TestItemBare.ValueToMakeValidationFail}");
 }
Exemple #27
0
 /// <inheritdoc />
 public virtual void Validate(string errorLocaction, string propertyPath = "")
 {
     FulcrumValidate.IsNotDefaultValue(Id, nameof(Id), errorLocaction);
     FulcrumValidate.IsNotNullOrWhiteSpace(Etag, nameof(Etag), errorLocaction);
 }
Exemple #28
0
 /// <inheritdoc />
 public override void Validate(string errorLocation, string propertyPath = "")
 {
     FulcrumValidate.IsNotNullOrWhiteSpace(GivenName, nameof(GivenName), errorLocation);
     FulcrumValidate.IsNotNullOrWhiteSpace(Surname, nameof(Surname), errorLocation);
 }
 /// <inheritdoc />
 public void Validate(string errorLocation, string propertyPath = "")
 {
     FulcrumValidate.IsNotNullOrWhiteSpace(ConceptName, nameof(ConceptName), errorLocation);
     FulcrumValidate.IsTrue(ClientName == null || ContextName == null, errorLocation, $"One of the properties {nameof(ContextName)} ({ContextName}) and {nameof(ClientName)} ({ClientName}) must be null.");
     FulcrumValidate.IsTrue(!string.IsNullOrWhiteSpace(ContextName) || !string.IsNullOrWhiteSpace(ClientName), errorLocation, $"One of the properties {nameof(ContextName)} ({ContextName}) and {nameof(ClientName)} ({ClientName}) must contain a name.");
 }
 /// <inheritdoc />
 public override void Validate(string errorLocation, string propertyPath = "")
 {
     base.Validate(errorLocation, propertyPath);
     FulcrumValidate.IsNotDefaultValue(MasterId, nameof(MasterId), errorLocation);
     FulcrumValidate.IsNotDefaultValue(SlaveId, nameof(SlaveId), errorLocation);
 }