Example #1
0
 public static void ShorterThan(int value, int minValue, string parameterName)
 {
     if (minValue > value)
     {
         throw new DomainException(DomainPreconditionMessages.GetShorterThan(minValue, parameterName));
     }
 }
Example #2
0
 public static void EarlierThan(DateTime?value, DateTime dateToCompare, string parameterName)
 {
     if (value.HasValue && value.Value >= dateToCompare)
     {
         throw new DomainException(DomainPreconditionMessages.GetEarlierThan(dateToCompare, parameterName));
     }
 }
Example #3
0
 public static void LengthEqualTo(string value, int requiredLength, string parameterName)
 {
     if (value?.Length != requiredLength)
     {
         throw new DomainException(DomainPreconditionMessages.GetLengthEqualTo(requiredLength, parameterName));
     }
 }
Example #4
0
 public static void NotEmpty(byte[] value, string parameterName)
 {
     if (value.Length <= 0)
     {
         throw new DomainException(DomainPreconditionMessages.GetNotEmpty(parameterName));
     }
 }
Example #5
0
 public static void LongerThan(int value, int maxValue, string parameterName)
 {
     if (value > maxValue)
     {
         throw new DomainException(DomainPreconditionMessages.GetLongerThan(maxValue, parameterName));
     }
 }
Example #6
0
 public static void IsIntInIntList(IEnumerable <int> intList, int value, string parameterName)
 {
     if (intList.All(i => i != value))
     {
         throw new DomainException(DomainPreconditionMessages.IsIntInIntList(parameterName));
     }
 }
Example #7
0
 public static void LessThanOrEqualTo(int quantity, int max, string parameterName)
 {
     if (quantity > max)
     {
         throw new DomainException(DomainPreconditionMessages.LessThanOrEqualTo(max, parameterName));
     }
 }
Example #8
0
 public static void GreaterThan(decimal quantity, decimal min, string parameterName)
 {
     if (quantity <= min)
     {
         throw new DomainException(DomainPreconditionMessages.GreaterThan(min, parameterName));
     }
 }
Example #9
0
 public static void EarlierOrEqualThan(DateTime start, DateTime end, string parameterName)
 {
     if (start > end)
     {
         throw new DomainException(DomainPreconditionMessages.GetEarlierOrEqualThan(end, parameterName));
     }
 }
Example #10
0
 public static void NotEmpty(string value, string parameterName)
 {
     if (string.IsNullOrWhiteSpace(value))
     {
         throw new DomainException(DomainPreconditionMessages.GetNotEmpty(parameterName));
     }
 }
Example #11
0
        public static IEnumerable <T> NotEmpty <T>(IEnumerable <T> values, string parameterName) where T : class
        {
            if (values != null && !values.Any())
            {
                throw new DomainException(DomainPreconditionMessages.GetNotEmptyCollection(parameterName));
            }

            return(values);
        }
Example #12
0
        public static void RegexMatch(string value, Regex regex, string parameterName)
        {
            var match = regex.Match(value);

            if (!match.Success)
            {
                throw new DomainException(DomainPreconditionMessages.GetSuccessMatch(parameterName));
            }
        }
Example #13
0
        public static T IntNotNull <T>(T value, int parameterName)
            where T : class
        {
            if (value is null)
            {
                throw new DomainException(DomainPreconditionMessages.GetNotNull(parameterName));
            }

            return(value);
        }