Skip to content

Instantly share code, notes, and snippets.

@davidalpert
Last active December 26, 2015 10:59
Show Gist options
  • Select an option

  • Save davidalpert/7140339 to your computer and use it in GitHub Desktop.

Select an option

Save davidalpert/7140339 to your computer and use it in GitHub Desktop.
FluentValidation question
RuleFor(x => x.EnteringAirTemperature)
.GreaterThanOrEqualTo(50)
.WithMessage("{0}", eat =>
{
if (40 <= eat.NumericValue && eat.NumericValue < 50)
{
return "An '{PropertyName}' value of '{PropertyValue}' requires low temperature construction. " +
"Please select LTAF or LTFF liners.";
}
return "'{PropertyName}' must be greater than or equal to '{ComparisonValue}.";
});
RuleFor(x => x.EnteringAirTemperature)
.GreaterThanOrEqualTo(50)
.When(x => x.NumericValue < 40);
RuleFor(x => x.EnteringAirTemperature)
.GreaterThanOrEqualTo(50)
.When(x => 40 <= x.NumericValue && x.NumericValue < 50)
.WithMessage(ReheatCoilValidation.RequiresLowTemperatureConstruction, eat => eat.NumericValue);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment