/// <summary> /// Validates that the parameter is assignable to <typeparamref name="TType" />. Otherwise, an <see cref="ArgumentException" /> is thrown. /// </summary> /// <typeparam name="TType">The type the parameter should be assignable to.</typeparam> /// <param name="validator">The <see cref="ParameterValidator{TParameter}" />.</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 is not assignable to <typeparamref name="TType" />.</exception> public static ParameterValidator <Type> IsAssignableTo <TType>(this ParameterValidator <Type> validator, string exceptionMessage) { return(validator.IsAssignableTo(typeof(TType), exceptionMessage)); }
/// <summary> /// Validates that the parameter is an interface. Otherwise, an <see cref="ArgumentException" /> is thrown. /// </summary> /// <param name="validator">The <see cref="ParameterValidator{TParameter}" />.</param> /// <returns>The same instance of <see cref="ParameterValidator{TParameter}" />.</returns> /// <exception cref="ArgumentException">Thrown when the parameter is not an interface.</exception> public static ParameterValidator <Type> IsInterface(this ParameterValidator <Type> validator) { return(validator.IsInterface(ExceptionMessages.VALUE_MUST_BE_AN_INTERFACE)); }
/// <summary> /// Validates that the parameter is assignable to <typeparamref name="TType" />. Otherwise, an <see cref="ArgumentException" /> is thrown. /// </summary> /// <typeparam name="TType">The type the parameter should be assignable to.</typeparam> /// <param name="validator">The <see cref="ParameterValidator{TParameter}" />.</param> /// <returns>The same instance of <see cref="ParameterValidator{TParameter}" />.</returns> /// <exception cref="ArgumentException">Thrown when the parameter is not assignable to <typeparamref name="TType" />.</exception> public static ParameterValidator <Type> IsAssignableTo <TType>(this ParameterValidator <Type> validator) { return(validator.IsAssignableTo(typeof(TType))); }
/// <summary> /// Validates that the parameter is a class. Otherwise, an <see cref="ArgumentException" /> is thrown. /// </summary> /// <param name="validator">The <see cref="ParameterValidator{TParameter}" />.</param> /// <returns>The same instance of <see cref="ParameterValidator{TParameter}" />.</returns> /// <exception cref="ArgumentException">Thrown when the parameter is not a class.</exception> public static ParameterValidator <Type> IsClass(this ParameterValidator <Type> validator) { return(validator.IsClass(ExceptionMessages.VALUE_MUST_BE_A_CLASS)); }
/// <summary> /// Validates that the parameter matches the specified regular expression <paramref name="regex" />. Otherwise, an <see cref="ArgumentException" /> is thrown. /// </summary> /// <param name="validator">The <see cref="ParameterValidator{TParameter}" />.</param> /// <param name="regex">The regular expression.</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 does not match <paramref name="regex" />.</exception> public static ParameterValidator <string> Match(this ParameterValidator <string> validator, Regex regex, string exceptionMessage) { Match match; return(validator.Match(regex, exceptionMessage, out match)); }
/// <summary> /// Validates that the parameter matches the specified regular expression <paramref name="pattern" />. Otherwise, an <see cref="ArgumentException" /> is thrown. /// </summary> /// <param name="validator">The <see cref="ParameterValidator{TParameter}" />.</param> /// <param name="pattern">The regular expression pattern.</param> /// <returns>The same instance of <see cref="ParameterValidator{TParameter}" />.</returns> /// <exception cref="ArgumentException">Thrown when the parameter does not match <paramref name="pattern" />.</exception> public static ParameterValidator <string> Match(this ParameterValidator <string> validator, string pattern) { Match match; return(validator.Match(pattern, out match)); }
/// <summary> /// Validates that the parameter is not null, empty or white space. Otherwise, an <see cref="ArgumentNullException" /> or <see cref="ArgumentException" /> is thrown. /// </summary> /// <param name="validator">The <see cref="ParameterValidator{TParameter}" />.</param> /// <returns>The same instance of <see cref="ParameterValidator{TParameter}" />.</returns> /// <exception cref="ArgumentNullException">Thrown when the parameter is null.</exception> /// <exception cref="ArgumentException">Thrown when the parameter is empty or white space.</exception> public static ParameterValidator <string> IsNotNullOrWhiteSpace(this ParameterValidator <string> validator) { return(validator.IsNotNullOrWhiteSpace(ExceptionMessages.VALUE_CANNOT_BE_NULL_EMPTY_OR_WHITE_SPACE)); }
/// <summary> /// Validates that the parameter is not null or empty. Otherwise, an <see cref="System.ArgumentException" /> is thrown. /// </summary> /// <param name="validator">The <see cref="ParameterValidator{TParameter}" />.</param> /// <returns>The same instance of <see cref="ParameterValidator{TParameter}" />.</returns> /// <exception cref="System.ArgumentException">Thrown when the parameter is null or empty.</exception> public static ParameterValidator <string> IsNotNullOrEmpty(this ParameterValidator <string> validator) { return(validator.IsNotNullOrEmpty(ExceptionMessages.VALUE_CANNOT_BE_NULL_OR_EMPTY)); }