M# Tutorials

Learn to build .NET applications with M#. Our step-by-step tutorials will get you up-to-speed rapidly.
If you already know ASP.NET and C#, you can master M# in a week or two.

Mutually Exclusive Mandatory

This tutorial explains handling mutually exclusive input validation. Mutually exclusive mandatory rules are applied when properties are reciprocal and you cannot set a value for both, only one can be populated at a time. This kind of validation should also be performed in “Validate” method, which should be overridden in the entity’s logic classes.

We often deal with a scenario where we ask user to select the contact preference i.e. by telephone or by email. Let’s say we display two bool type properties “ContactByTelephone” and “ContactByEmail” a registration form. We can perform a mutual exclusive validation to make only one property mandatory as shown in below screenshot