public static Param <string> IsNotNullOrWhiteSpace(this Param <string> param) { if (string.IsNullOrWhiteSpace(param.Value)) { throw ExceptionFactory.CreateForParamValidation(param, Properties.Ensure.Ensure_IsNotNullOrWhiteSpace); } return(param); }
public static TypeParam IsOfType(this TypeParam param, Type type) { if (!param.Type.Equals(type)) { throw ExceptionFactory.CreateForParamValidation(param, Properties.Ensure.Ensure_IsNotOfType.Inject(param.Type.FullName)); } return(param); }
public static Param <double> IsInRange(this Param <double> param, double min, double max) { if (param.Value < min) { throw ExceptionFactory.CreateForParamValidation(param, Properties.Ensure.Ensure_IsNotInRange_ToLow.Inject(param.Value, min)); } if (param.Value > max) { throw ExceptionFactory.CreateForParamValidation(param, Properties.Ensure.Ensure_IsNotInRange_ToHigh.Inject(param.Value, max)); } return(param); }
public static Param <Type> IsClass(this Param <Type> param) { if (param.Value == null) { throw ExceptionFactory.CreateForParamValidation(param, Properties.Ensure.Ensure_IsNotClass_WasNull); } if (!param.Value.IsClass) { throw ExceptionFactory.CreateForParamValidation(param, Properties.Ensure.Ensure_IsNotClass.Inject(param.Value.FullName)); } return(param); }
public static Param <string> HasLengthBetween(this Param <string> param, int minLength, int maxLength) { if (string.IsNullOrEmpty(param.Value)) { throw ExceptionFactory.CreateForParamValidation(param, Properties.Ensure.Ensure_IsNotNullOrEmpty); } var length = param.Value.Length; if (length < minLength) { throw ExceptionFactory.CreateForParamValidation(param, Properties.Ensure.Ensure_IsNotInRange_ToShort.Inject(minLength, maxLength, length)); } if (length > maxLength) { throw ExceptionFactory.CreateForParamValidation(param, Properties.Ensure.Ensure_IsNotInRange_ToLong.Inject(minLength, maxLength, length)); } return(param); }