title: FluentValidation: Check if one of two fields are empty
body: <p>I have this <strong>model</strong></p>
  
  <pre><code>public class Person
  {
      public int Id { get; set; }
      public string FirstName { get; set; }
      public string LastName { get; set; }  
  }
  </code></pre>
  
  <p>I want to create a validation where either FirstName or LastName must be filled in by user.
  I installed <code>FluentValidation</code> and created a <strong>customvalidator class</strong></p>
  
  <pre><code>public class PersonValidator:AbstractValidator&lt;Person&gt;
  {
      public PersonValidator()
      {
          RuleFor((person=&gt;person.FirstName)//don't know how to check if one is empty
      }
  }
  </code></pre>
  
  <p>To check just one field I could just do <code>RuleFor(person =&gt; person.FirstName).NotNull();</code></p>
  
  <p>But how do I check if one of them is null.</p>
  
  <p>Also, is it possible, once validation is created via <code>fluentValidation</code>, use it on the client side to show error?</p>
  
  <p><strong>Edit1</strong></p>
  
  <pre><code>    protected void Application_Start()
      {
          AreaRegistration.RegisterAllAreas();
  
          FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
          RouteConfig.RegisterRoutes(RouteTable.Routes);
          BundleConfig.RegisterBundles(BundleTable.Bundles);
          FluentValidationModelValidatorProvider.Configure();
      }
  //creating validation
  namespace WebApplication1.Models.CustomValidator
  {
      public class PersonValidator:AbstractValidator&lt;Person&gt;
      {
          public PersonValidator()
          {
              RuleFor(m =&gt; m.FirstName).NotEmpty().When(m =&gt; string.IsNullOrEmpty(m.LastName)).WithMessage("*Either First Name or Last Name is required");
              RuleFor(m =&gt; m.LastName).NotEmpty().When(m =&gt; string.IsNullOrEmpty(m.FirstName)).WithMessage("*Either First Name or Last Name is required");
          }
      }
  
  }
  //model class
  [Validator(typeof(PersonValidator))]
  public class Person
  {
      public Person()
      {
          InterestList = new List&lt;string&gt;();
      }
      public int Id { get; set; }
      public int ContactId { get; set; }
      [RequiredIfEmpty("LastName")]
      public string FirstName { get; set; }
      [RequiredIfEmpty("FirstName")]
      public string LastName { get; set; }
      public string EmailAddress { get; set; }
      public string Phone { get; set; }
      public string Country { get; set; }
      public List&lt;string&gt; InterestList { get; set; } 
  }
  //view
  @model WebApplication1.Models.Person
  
  &lt;script src="@Url.Content("~/Scripts/jquery-1.8.2.min.js")"&gt;&lt;/script&gt;
  &lt;script src="@Url.Content("~/Scripts/jquery.validate.min.js")"&gt;&lt;/script&gt;
  &lt;script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")"&gt;&lt;/script&gt;
  &lt;script src="@Url.Content("~/Scripts/jquery.unobtrusive-ajax.min.js")" type="text/javascript"&gt;&lt;/script&gt;
  
  @Html.ValidationSummary(true)
  @using(Html.BeginForm("AddPerson","Person",FormMethod.Post))
  {
      &lt;div class="label"&gt;First Name&lt;/div&gt;
      &lt;div class="input-block-level"&gt;@Html.TextBoxFor(m=&gt;m.FirstName)@Html.ValidationMessageFor(m=&gt;m.FirstName)&lt;/div&gt;
      &lt;br/&gt;
      &lt;div class="label"&gt;Last Name&lt;/div&gt;
      &lt;div class="input-block-level"&gt;@Html.TextBoxFor(m=&gt;m.LastName)@Html.ValidationMessageFor(m=&gt;m.LastName)&lt;/div&gt;
      &lt;button type="submit" class="btn-primary"&gt;Submit&lt;/button&gt;
  }
  </code></pre>