Esempio n. 1
0
 /// <summary>
 /// If the received value is null, <see cref="ValidationException"/>
 /// is emitted as an error with the status code 404 (Not Found).
 /// Otherwise the given value is emitted.
 /// </summary>
 /// <typeparam name="TSource">The type of the value.</typeparam>
 /// <param name="observable">The parent observable.</param>
 /// <param name="errorFactory">The error factory method.</param>
 /// <returns>An instance of <see cref="IProviderObservable{TSource}"/>.</returns>
 public static IProviderObservable <TSource> NotFoundWhenNull <TSource>(
     this IProviderObservable <TSource> observable,
     Func <TSource, object> errorFactory = null) =>
 observable.InvalidWhen(s => s == null, StatusCodes.Status404NotFound, errorFactory);
Esempio n. 2
0
 /// <summary>
 /// If the check returns <c>true</c>, <see cref="ValidationException"/>
 /// is emitted as an error with the status code 404 (Not Found).
 /// Otherwise the given value is emitted.
 /// </summary>
 /// <typeparam name="TSource">The type of the value.</typeparam>
 /// <param name="observable">The parent observable.</param>
 /// <param name="invalidCheck">The invalidCheck function.</param>
 /// <param name="errorFactory">The error factory method.</param>
 /// <returns>An instance of <see cref="IProviderObservable{TSource}"/>.</returns>
 public static IProviderObservable <TSource> NotFoundWhen <TSource>(
     this IProviderObservable <TSource> observable,
     Func <bool> invalidCheck,
     Func <TSource, object> errorFactory = null) =>
 observable.InvalidWhen(
     s => invalidCheck(), StatusCodes.Status404NotFound, errorFactory);
Esempio n. 3
0
 /// <summary>
 /// If the check returns <c>true</c>, <see cref="ValidationException"/>
 /// is emitted as an error with the status code 404 (Not Found).
 /// Otherwise the given value is emitted.
 /// </summary>
 /// <typeparam name="TSource">The type of the value.</typeparam>
 /// <param name="observable">The parent observable.</param>
 /// <param name="invalidCheck">The invalidCheck function.</param>
 /// <param name="error">The error to be used on a failed check.</param>
 /// <returns>An instance of <see cref="IProviderObservable{TSource}"/>.</returns>
 public static IProviderObservable <TSource> NotFoundWhen <TSource>(
     this IProviderObservable <TSource> observable,
     Func <bool> invalidCheck,
     object error) =>
 observable.InvalidWhen(
     s => invalidCheck(), StatusCodes.Status404NotFound, s => error);
 /// <summary>
 /// If the check returns <c>true</c>, <see cref="ValidationException"/>
 /// is emitted as an error with the status code 400 (Bad Request).
 /// Otherwise the given value is emitted.
 /// </summary>
 /// <typeparam name="TSource">The type of the value.</typeparam>
 /// <param name="observable">The parent observable.</param>
 /// <param name="invalidCheck">The invalidCheck function.</param>
 /// <param name="error">The error to be used on a failed check.</param>
 /// <returns>An instance of <see cref="IProviderObservable{TSource}"/>.</returns>
 public static IProviderObservable <TSource> BadRequestWhen <TSource>(
     this IProviderObservable <TSource> observable,
     Func <TSource, bool> invalidCheck,
     object error) =>
 observable.InvalidWhen(invalidCheck, StatusCodes.Status400BadRequest, s => error);
 /// <summary>
 /// If the check returns <c>true</c>, <see cref="ValidationException"/>
 /// is emitted as an error with the status code 410 (Gone).
 /// Otherwise the given value is emitted.
 /// </summary>
 /// <typeparam name="TSource">The type of the value.</typeparam>
 /// <param name="observable">The parent observable.</param>
 /// <param name="invalidCheck">The invalidCheck function.</param>
 /// <param name="errorFactory">The error factory method.</param>
 /// <returns>An instance of <see cref="IProviderObservable{TSource}"/>.</returns>
 public static IProviderObservable <TSource> GoneWhen <TSource>(
     this IProviderObservable <TSource> observable,
     Func <TSource, bool> invalidCheck,
     Func <TSource, object> errorFactory = null) =>
 observable.InvalidWhen(invalidCheck, StatusCodes.Status410Gone, errorFactory);
Esempio n. 6
0
 /// <summary>
 /// If the check returns <c>true</c>, <see cref="ValidationException"/>
 /// is emitted as an error with the given status code.
 /// Otherwise the given value is emitted.
 /// </summary>
 /// <typeparam name="TSource">The type of the value.</typeparam>
 /// <param name="observable">The parent observable.</param>
 /// <param name="invalidCheck">The invalidCheck function.</param>
 /// <param name="statusCode">The status code of the error.</param>
 /// <param name="error">The error to be used on a failed check.</param>
 /// <returns>An instance of <see cref="IProviderObservable{TSource}"/>.</returns>
 public static IProviderObservable <TSource> InvalidWhen <TSource>(
     this IProviderObservable <TSource> observable,
     Func <bool> invalidCheck,
     int statusCode,
     object error) =>
 observable.InvalidWhen(s => invalidCheck(), statusCode, s => error);
Esempio n. 7
0
 /// <summary>
 /// If the check returns <c>true</c>, <see cref="ValidationException"/>
 /// is emitted as an error with the given status code.
 /// Otherwise the given value is emitted.
 /// </summary>
 /// <typeparam name="TSource">The type of the value.</typeparam>
 /// <param name="observable">The parent observable.</param>
 /// <param name="invalidCheck">The invalidCheck function.</param>
 /// <param name="statusCode">The status code of the error.</param>
 /// <param name="errorFactory">The error factory method.</param>
 /// <returns>An instance of <see cref="IProviderObservable{TSource}"/>.</returns>
 public static IProviderObservable <TSource> InvalidWhen <TSource>(
     this IProviderObservable <TSource> observable,
     Func <bool> invalidCheck,
     int statusCode,
     Func <TSource, object> errorFactory = null) =>
 observable.InvalidWhen(s => invalidCheck(), statusCode, errorFactory);
Esempio n. 8
0
 /// <summary>
 /// If the check returns <c>true</c>, <see cref="ValidationException"/>
 /// is emitted as an error with the status code 403 (Forbidden).
 /// Otherwise the given value is emitted.
 /// </summary>
 /// <typeparam name="TSource">The type of the value.</typeparam>
 /// <param name="observable">The parent observable.</param>
 /// <param name="invalidCheck">The invalidCheck function.</param>
 /// <param name="error">The error to be used on a failed check.</param>
 /// <returns>An instance of <see cref="IProviderObservable{TSource}"/>.</returns>
 public static IProviderObservable <TSource> ForbiddenWhen <TSource>(
     this IProviderObservable <TSource> observable,
     Func <TSource, bool> invalidCheck,
     object error) =>
 observable.InvalidWhen(invalidCheck, StatusCodes.Status403Forbidden, s => error);