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

  • Home
  • SEARCH
  • 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 6196635
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T03:40:44+00:00 2026-05-24T03:40:44+00:00

I have problem with Fluent Validation. I want to check the validation so the

  • 0

I have problem with Fluent Validation.

I want to check the validation so the property must be filled greater than another property.
here is the code :

public decimal? MonthlySalesNet { get; set; }
public decimal? MonthlySalesGross { get; set; }

and here is the validation :

RuleFor(x => x.MonthlySalesGross.Value).GreaterThan(x => x.MonthlySalesNet.Value)
            .When(x => x.MonthlySalesGross != null && x.MonthlySalesNet != null)
            .WithMessage("blahblah");

the validation was working but the message was not shown. am I missing something?

when I was changed decimal to not nullable type and reconfigure the validation, the error message validation was shown. it`s weird for me,,Thanks

  • 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-24T03:40:45+00:00Added an answer on May 24, 2026 at 3:40 am

    (I posted the same answer over on the FV forum)

    The message doesn’t display because it thinks it’s associated with the wrong property. When you use RuleFor(x => x.MonthlySalesGross.Value), it associates the rule with a property called “Value” rather than with the MonthlySalesGross property.

    FluentValidation v3 adds better support for nullables (I blogged about this here), but at present this only works with constant values, not expressions that reference other properties. I’m planning to expand the nullable support to work with cross-property validators with v3.1, but for now you can work around this by manually overriding the property name. This will re-associate the error with the correct property:

    RuleFor(x => x.MonthlySalesGross.Value)
        .GreaterThan(x => x.MonthlySalesNet.Value)
        .When(x => x.MonthlySalesGross.HasValue)
        .OverridePropertyName("MonthlySalesGross");
    

    (note that you also have to include a null check with a When clause).

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

Sidebar

Related Questions

I have a problem with one-to-one relationships in the fluent nHibernate. I have the
I am very new to Fluent NHibernate and I have a problem that I
I have a FluentValidation validator that I want to use to validate a booking.
I'm having a problem with Fluent NHibernate mappings, I think, and can't quite get
I have a list of this object: public class Customer { public int Id
I have a problem constructing a DSL in Clojure. This is the concrete problem
I have a piece of software written with fluent syntax. The method chain has
I have some classes that i'd like chain methods of to provide a fluent
I am using fluent nhibernate(v1.2) and nhibernate(v3.1) and I am having a weird Problem.
There are lots of Fluent implementations out there now that work with Lambdas to

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.