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