/// <summary> /// Validates that the parameter is greater than or equal to the <paramref name="minLength"/> and less than or equal to <paramref name="maxLength" />. Otherwise, an <see cref="ArgumentException" /> is thrown. /// </summary> /// <param name="validator">The <see cref="ParameterValidator{TParameter}" />.</param> /// <param name="minLength">The minimum length.</param> /// <param name="maxLength">The maximum length.</param> /// <param name="exceptionMessage">The exception message.</param> /// <returns>The same instance of <see cref="ParameterValidator{TParameter}" />.</returns> /// <exception cref="ArgumentException">Thrown when the parameter length is not greater than or equal to the <paramref name="minLength" /> and less than or equal to <paramref name="maxLength"/>.</exception> public static ParameterValidator <string> HasLengthBetween(this ParameterValidator <string> validator, int minLength, int maxLength, string exceptionMessage) { validator.HasMinLength(minLength, exceptionMessage) .HasMaxLength(maxLength, exceptionMessage); return(validator); }
/// <summary> /// Validates that the parameter is greater than or equal to the <paramref name="minLength"/>. Otherwise, an <see cref="ArgumentException" /> is thrown. /// </summary> /// <param name="validator">The <see cref="ParameterValidator{TParameter}" />.</param> /// <param name="minLength">The minimum length.</param> /// <returns>The same instance of <see cref="ParameterValidator{TParameter}" />.</returns> /// <exception cref="ArgumentException">Thrown when the parameter length is not greater than or equal to the <paramref name="minLength" />.</exception> public static ParameterValidator <string> HasMinLength(this ParameterValidator <string> validator, int minLength) { if (validator.Value == null) { return(validator); } string exceptionMessage = string.Format(ExceptionMessages.VALUE_MUST_HAVE_LENGTH_GREATER_THAN_OR_EQUAL_TO, minLength.ToString()); return(validator.HasMinLength(minLength, exceptionMessage)); }