예제 #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}\".");
 }