/// <summary> /// Validates a parameter is less than or equal to <paramref name="value" />. Otherwise, an <see cref="ArgumentOutOfRangeException" /> is thrown. /// </summary> /// <typeparam name="TParameter">The parameter type.</typeparam> /// <param name="validator">The <see cref="ParameterValidator{TParameter}" />.</param> /// <param name="value">The value the parameter must be less than or equal to.</param> /// <returns>The same instance of <see cref="ParameterValidator{TParameter}" />.</returns> /// <exception cref="ArgumentOutOfRangeException">Thrown when the parameter is not less or equal to than <paramref name="value" />.</exception> public static ParameterValidator <TParameter?> IsLessThanOrEqualTo <TParameter>(this ParameterValidator <TParameter?> validator, TParameter?value) where TParameter : struct, IComparable <TParameter> { if (validator.Value == null || value == null) { return(validator); } string exceptionMessage = string.Format(ExceptionMessages.VALUE_MUST_BE_LESS_THAN_OR_EQUAL_TO, value.ToString()); return(validator.IsLessThanOrEqualTo(value, exceptionMessage)); }