コード例 #1
0
 public static void NotDefined <T>([NotNull] this IValueValidatorClause valueValidatorClause, [NotNull] object input)
     where T : Enum
 {
     if (!Enum.IsDefined(typeof(T), input))
     {
         throw new ArgumentException($"The given input is not defined or does not exist.");
     }
 }
コード例 #2
0
        public static T Null <T>([NotNull] this IValueValidatorClause valueValidatorClause, [NotNull] T input, [NotNull] string parameterName)
        {
            if (input is null)
            {
                throw new ArgumentException($"The given input {parameterName} was null.", parameterName);
            }

            return(input);
        }
コード例 #3
0
        public static bool True([NotNull] this IValueValidatorClause valueValidatorClause, [NotNull] bool input, [NotNull] string message)
        {
            if (input)
            {
                throw new InvalidOperationException(message);
            }

            return(input);
        }
コード例 #4
0
        public static Guid NullOrEmpty([NotNull] this IValueValidatorClause valueValidatorClause, [NotNull] Guid?input, [NotNull] string parameterName)
        {
            ValueValidator.ThrowsWhen.Null(input, parameterName);

            if (input.Equals(Guid.Empty))
            {
                throw new ArgumentException($"The given input {parameterName} was null or empty.", parameterName);
            }

            return(input.Value);
        }
コード例 #5
0
        public static string NullOrWhiteSpace([NotNull] this IValueValidatorClause valueValidatorClause, [NotNull] string input, [NotNull] string parameterName)
        {
            ValueValidator.ThrowsWhen.Null(input, parameterName);

            if (string.IsNullOrWhiteSpace(input))
            {
                throw new ArgumentException($"The given input {parameterName} was null or empty.", parameterName);
            }

            return(input);
        }
コード例 #6
0
        public static T Null <T>([NotNull] this IValueValidatorClause valueValidatorClause, T input, [NotNull] string parameterName, string message)
        {
            if (string.IsNullOrWhiteSpace(message))
            {
                return(ValueValidator.ThrowsWhen.Null(input, parameterName));
            }

            if (input is null)
            {
                throw new InvalidOperationException(message);
            }

            return(input);
        }