title: FluentValidation Validator using arguments
body: <p>I have a FluentValidation validator that I want to use to validate a booking. On a booking you must choose a room type that exists as an available room type on the tour that you are choosing. I need to get the available room types from a service, passing in the code for the tour. What is the best way to handle getting the tour code where it needs to be?</p>
  
  <p>What I've got so far:</p>
  
  <pre><code>public class BookingValidator : AbstractValidator&lt;Booking&gt;, IBookingValidator
  
  public BookingValidator()
  {
      RuleFor(booking =&gt; booking.Rooms).SetValidator(new RoomValidator())
  }
  
  public class RoomValidator : AbstractValidator&lt;Room&gt;
  
  public RoomValidator()
  {
      //validate that room.Type (eg. TWIN) exists in availableRoomTypes (eg List&lt;string&gt; {'SINGLE','TWIN'}
  }
  </code></pre>
  
  <p>Some hack at the problem:</p>
  
  <pre><code>public class BookingValidator : AbstractValidator&lt;Booking&gt;
  
  //should/can i pass in arguments here when IoC container is wiring up IBookingValidator to BookingValidator? Seems awkward
  public BookingValidator(string tourCode)
  {
  
  //if so, use argument to get available room types, pass to RoomValidator
  var availableRooms = RoomTypeService.GetAvailableRoomTypesForTour(tourCode);
  
  RuleFor(booking =&gt; booking.Rooms).SetValidator(new RoomValidator(availableRooms))
  
  //alternatively, tourCode is available from booking - is there some way to pass it to RoomValidator?
  RuleFor(booking =&gt; booking.Rooms).SetValidator(new RoomValidator(),booking =&gt; booking.TourCode);
  
  //Or is there some way I should be using .Must() or Custom()??
  
  }
  </code></pre>
  
  <p>So the main problem is how or where to get tour code into the validator...?</p>