Пример #1
0
 /// <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);
 }
Пример #2
0
 /// <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);
 }
Пример #3
0
 /// <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);
 }
Пример #4
0
 /// <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 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);
 }
 /// <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 = "")
 {
     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);
 }
Пример #8
0
 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 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);
 }
Пример #10
0
 /// <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);
 }
Пример #11
0
        /// <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.");
                    }
                }
            }
        }
Пример #12
0
 public void Validate(string errorLocation, string propertyPath = "")
 {
     FulcrumValidate.IsNotNullOrWhiteSpace(Name, nameof(Name), null);
     FulcrumValidate.IsNotNullOrWhiteSpace(Type, nameof(Type), null);
 }
 /// <inheritdoc />
 public void Validate(string errorLocation, string propertyPath = "")
 {
     FulcrumValidate.IsNotNullOrWhiteSpace(Etag, nameof(Etag), errorLocation);
 }
Пример #14
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);
 }
Пример #15
0
 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);
 }
Пример #17
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);
 }
Пример #18
0
 /// <inheritdoc />
 public void Validate(string errorLocation, string propertyPath = "")
 {
     FulcrumValidate.IsNotNullOrWhiteSpace(ClientName, nameof(ClientName), errorLocation);
     FulcrumValidate.IsNotNullOrWhiteSpace(EntityName, nameof(EntityName), errorLocation);
     // Value can be null when creating objects
 }
Пример #19
0
 /// <inheritdoc />
 public void Validate(string errorLocation, string propertyPath = "")
 {
     FulcrumValidate.IsNotNullOrWhiteSpace(Longitude, nameof(Longitude), errorLocation);
     FulcrumValidate.IsNotNullOrWhiteSpace(Latitude, nameof(Latitude), errorLocation);
 }
Пример #20
0
 /// <inheritdoc />
 public virtual void Validate(string errorLocaction, string propertyPath = "")
 {
     FulcrumValidate.IsNotDefaultValue(Id, nameof(Id), errorLocaction);
     FulcrumValidate.IsNotNullOrWhiteSpace(Etag, nameof(Etag), errorLocaction);
 }
Пример #21
0
 /// <inheritdoc />
 public override void Validate(string errorLocation, string propertyPath = "")
 {
     FulcrumValidate.IsNotNullOrWhiteSpace(GivenName, nameof(GivenName), errorLocation);
     FulcrumValidate.IsNotNullOrWhiteSpace(Surname, nameof(Surname), errorLocation);
 }
Пример #22
0
 /// <inheritdoc />
 public void Validate(string errorLocation, string propertyPath = "")
 {
     FulcrumValidate.IsNotNullOrWhiteSpace(City, nameof(City), errorLocation);
     FulcrumValidate.IsNotDefaultValue(PersonId, nameof(PersonId), 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.");
 }
Пример #24
0
 /// <inheritdoc />
 public void Validate(string errorLocation, string propertyPath = "")
 {
     FulcrumValidate.IsNotNullOrWhiteSpace(Name, nameof(Name), errorLocation);
     FulcrumValidate.IsNotNullOrWhiteSpace(Type, nameof(Type), errorLocation);
     FulcrumValidate.IsTrue(Type == "int" || Type == "ext", errorLocation, $"Type must be either \"ext\" or \"int\", was \"{Type}\".");
 }