private static IValidationDef <T> IsBetweenImpl <T>(this IValidationDef <T> validationDef, T value, T and)
     where T : struct, IComparable, IComparable <T>, IConvertible, IEquatable <T>, IFormattable
 => validationDef.Is(
     predicate : arg =>
     (Comparer <T> .Default.Compare(arg, value) >= 0 && Comparer <T> .Default.Compare(arg, and) <= 0) ||
     (Comparer <T> .Default.Compare(arg, value) <= 0 && Comparer <T> .Default.Compare(arg, and) >= 0),
     message : $"Argument not valid, $name$ is $actualValue$ but expected to be between {value} and {and}.",
     validValues : value);
        public static IValidationDef <T?> IsValidEnum <T>(this IValidationDef <T?> validationDef)
            where T : struct
        {
            if (typeof(T).IsEnum == false)
            {
                return(validationDef.Is(
                           predicate: _ => false,
                           message: $"Argument not valid, $name$ is expected to be of an enum type. {typeof(T).Name} is not an enum"));
            }

            return(validationDef.Is(
                       predicate: arg => arg == null || typeof(T).IsEnumDefined(arg.Value),
                       message: "Argument not valid, $name$ is $actualValue$ but expected to be one of $validValues$.",
                       validValues: typeof(T).GetEnumNames()));
        }
 public static IValidationDef <string> Contains(this IValidationDef <string> validationDef, string value)
 => validationDef.Is(
     predicate: arg => arg != null && value != null && arg.Contains(value),
     message: "Argument not valid, $name$ is $actualValue$ but accepted value should contain $validValues$.",
     validValues: value);
 public static IValidationDef <T?> IsEqualTo <T>(this IValidationDef <T?> validationDef, T value) where T : struct
 => validationDef.Is(
     predicate : arg => arg.HasValue && EqualityComparer <T> .Default.Equals(arg.Value, value),
     message : "Argument not valid, $name$ is $actualValue$ but expected to be equal to $validValues$.",
     validValues : value);
 public static IValidationDef <T> IsNotEqualTo <T>(this IValidationDef <T> validationDef, T value)
 => validationDef.IsNot(
     predicate: arg => EqualityComparer <T> .Default.Equals(arg, value),
     message: "Argument not valid, $name$ is not expected to be equal to $actualValue$.",
     validValues: value);
 private static IValidationDef <T?> IsLessThanNullableImpl <T>(this IValidationDef <T?> validationDef, T value)
     where T : struct, IComparable, IComparable <T>, IConvertible, IEquatable <T>, IFormattable
 => validationDef.Is(
     predicate : arg => arg.HasValue && Comparer <T> .Default.Compare(arg.Value, value) < 0,
     message : "Argument not valid, $name$ is $actualValue$ but expected to be less than $validValues$.",
     validValues : value);
 public static IValidationDef <T> IsIn <T>(this IValidationDef <T> validationDef, params T[] values)
 => validationDef.Is(
     predicate: arg => arg.In(values),
     message: "Argument not valid, $name$ is $actualValue$ but accepted values are $validValues$.",
     validValues: values);
 private static IValidationDef <T> IsGreaterThanImpl <T>(this IValidationDef <T> validationDef, T value)
     where T : struct, IComparable, IComparable <T>, IConvertible, IEquatable <T>, IFormattable
 => validationDef.Is(
     predicate : arg => Comparer <T> .Default.Compare(arg, value) > 0,
     message : "Argument not valid, $name$ is $actualValue$ but expected to be greater than $validValues$.",
     validValues : value);
 public static IValidationDef <DateTime> IsBetween(this IValidationDef <DateTime> validationDef, DateTime value, DateTime and)
 => IsBetweenImpl(validationDef, value, and);
 public static IValidationDef <DateTime> IsLessThan(this IValidationDef <DateTime> validationDef, DateTime value)
 => IsLessThanImpl(validationDef, value);
 public static IValidationDef <int?> IsLessThan(this IValidationDef <int?> validationDef, int value)
 => IsLessThanNullableImpl(validationDef, value);
 public static IValidationDef <int> IsLessThan(this IValidationDef <int> validationDef, int value)
 => IsLessThanImpl(validationDef, value);
 public static IValidationDef <T> IsNotNull <T>(this IValidationDef <T> validationDef) where T : class
 => validationDef.IsNot(
     predicate : arg => arg == null,
     message : "Argument not valid, $name$ is null but expected to be non-null.");
 public static IValidationDef <DateTime?> IsBetween(this IValidationDef <DateTime?> validationDef, DateTime value, DateTime and)
 => IsBetweenNullableImpl(validationDef, value, and);
 public static IValidationDef <DateTime?> IsLessThan(this IValidationDef <DateTime?> validationDef, DateTime value)
 => IsLessThanNullableImpl(validationDef, value);
 public static IValidationDef <string> IsNotEmpty(this IValidationDef <string> validationDef)
 => validationDef.IsNot(
     predicate: string.IsNullOrEmpty,
     message: "Argument not valid, $name$ is $actualValue$ but expected to be non-empty.");
 public static IValidationDef <double?> IsBetween(this IValidationDef <double?> validationDef, double value, double and)
 => IsBetweenNullableImpl(validationDef, value, and);