Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 959427
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T01:01:30+00:00 2026-05-16T01:01:30+00:00

I have a fluent validation API that throws an exception when a supplied boolean

  • 0

I have a fluent validation API that throws an exception when a supplied boolean result is false. This works fine.

I’d like to improve upon this by, instead of throwing an exception, providing some functionality to execute if the result is false, and then forcing the calling method to return. Example, the supplied functionality might new up a response, initialise it appropriately and return it.

Is doing this even possible? (I suspect not).

Work around seems to be something like initializing an out param (the response), and returning that from the calling method.

Desired:

Ensure.That(request.IsValid(), () => new Response { Errors = request.Errors }); //I want lambda to force containing method reeturn

As implemented:

Response response;
            Ensure.That(request.IsValid(), r => new Response{Errors = request.Errors}, out response);
            if (response.IsNotNull()) return response;
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T01:01:31+00:00Added an answer on May 16, 2026 at 1:01 am

    The calling method has to know to do it, basically. How you signal that is up to you – a return value, an out parameter etc – but you can’t force it from the delegate itself other than with an exception (which could still be caught, of course).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a fluent, extensible validation helper like: Assert.That(aParameter).IsNotNull(); It is extensible because the
I have this table structure and would like to map it using Fluent Hibernate
I have a Fluent nHibernate data tier that I would like to use in
I have a class that is mapped in fluent nhibernate but I want one
I have a WPF Application using Fluent NHibernate 1.0 RTM and System.Data.SQLite 1.0.65 that
I have an ASP.NET MVC application that uses Fluent NHibernate and AutoMapper. I am
I have a question about defining Foreign Key in EF Code First Fluent API.
I have, let's say, this simple class: public class User { [Required(AllowEmptyStrings = false,
I have created a servicestack MVC project, this I use as the main API
I'm learning to use NHibernate validator and it's Fluent API (Loquacious). I have noticed

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.