We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
If we need to read a content on validation like this
let validateResponse (content:HttpContent) = task { let! result = content.ReadAsStringAsync() let! stream = content.ReadAsStreamAsync() stream.Seek(0L, SeekOrigin.Begin) |>ignore return not <| result.StartsWith("<!DOCTYPE html>") }
then validator must be asynchronous like this
let validateAsync<'TContext, 'TSource> (predicate: 'TSource -> Task<bool>) (source: Pipeline<'TContext, 'TSource>) : Pipeline<'TContext, 'TSource> = fun next -> { new IAsyncNext<'TContext, 'TSource> with member _.OnSuccessAsync(ctx, value) = task{ let! isValid = predicate value if isValid then return! next.OnSuccessAsync(ctx, value) else return! next.OnErrorAsync(ctx, SkipException "Validation failed") } member _.OnErrorAsync(ctx, exn) = next.OnErrorAsync(ctx, exn) member _.OnCancelAsync(ctx) = next.OnCancelAsync(ctx) } |> source
The text was updated successfully, but these errors were encountered:
No branches or pull requests
If we need to read a content on validation like this
then validator must be asynchronous like this
The text was updated successfully, but these errors were encountered: