public static Param <T[]> HasItems <T>(this Param <T[]> param)
        {
            if (!Ensure.IsActive)
            {
                return(param);
            }

            if (param.Value == null)
            {
                throw ExceptionFactory.CreateForParamNullValidation(param, ExceptionMessages.Common_IsNotNull_Failed);
            }

            if (param.Value.Length < 1)
            {
                throw ExceptionFactory.CreateForParamValidation(param, ExceptionMessages.Collections_HasItemsFailed);
            }

            return(param);
        }
Beispiel #2
0
        public static Param <string> HasLengthBetween(this Param <string> param, int minLength, int maxLength)
        {
            if (param.Value == null)
            {
                throw ExceptionFactory.CreateForParamNullValidation(param, ExceptionMessages.Common_IsNotNull_Failed);
            }

            var length = param.Value.Length;

            if (length < minLength)
            {
                throw ExceptionFactory.CreateForParamValidation(param, ExceptionMessages.Strings_HasLengthBetween_Failed_ToShort.Inject(minLength, maxLength, length));
            }

            if (length > maxLength)
            {
                throw ExceptionFactory.CreateForParamValidation(param, ExceptionMessages.Strings_HasLengthBetween_Failed_ToLong.Inject(minLength, maxLength, length));
            }

            return(param);
        }
        public static Param <Type> IsClass(this Param <Type> param)
        {
            if (!Ensure.IsActive)
            {
                return(param);
            }

            if (param.Value == null)
            {
                throw ExceptionFactory.CreateForParamNullValidation(param,
                                                                    ExceptionMessages.Types_IsClass_Failed_Null);
            }

            if (!param.Value.GetTypeInfo().IsClass)
            {
                throw ExceptionFactory.CreateForParamValidation(param,
                                                                ExceptionMessages.Types_IsClass_Failed.Inject(param.Value.FullName));
            }

            return(param);
        }