Jules
Jules

Reputation: 1081

mulitple when conditions with fluent validation

i need to specify multiple conditions in a 'when' clause for fv.

so i want to do this

When(day => day.sunny.Equals(false) and  day.rain.Equals(true), () =>
    {
        //rules would go in here
    });

Clearly the 'and' wont work but i cant find an example of the correct syntax.

Upvotes: 0

Views: 3253

Answers (1)

Jon Skeet
Jon Skeet

Reputation: 1499770

Sounds like you want:

When(day => day.sunny.Equals(false) && day.rain.Equals(true), () =>
{
    // Stuff
});

It's just normal C#, after all.

By the way, if sunny and rain are just bool values, I think this is far more readable:

When(day => !day.sunny && day.rain, () =>
{
    // Stuff
});

Upvotes: 10

Related Questions