<?xml version="1.0" encoding="utf-8" ?>

<objects xmlns="http://www.springframework.net" xmlns:v="http://www.springframework.net/validation">

  <v:group id="tripValidator">

    <v:required id="departureAirportValidator" test="StartingFrom.AirportCode">
      <v:message id="error.departureAirport.required" providers="departureAirportErrors, validationSummary"/>
    </v:required>

    <v:group id="destinationAirportValidator">
      <v:required test="ReturningFrom.AirportCode">
        <v:message id="error.destinationAirport.required" providers="destinationAirportErrors, validationSummary"/>
      </v:required>
      <v:condition test="ReturningFrom.AirportCode != StartingFrom.AirportCode" when="ReturningFrom.AirportCode != ''">
        <v:message id="error.destinationAirport.sameAsDeparture" providers="destinationAirportErrors, validationSummary"/>
      </v:condition>
    </v:group>

    <v:group id="departureDateValidator">
      <v:required test="StartingFrom.Date">
        <v:message id="error.departureDate.required" providers="departureDateErrors, validationSummary"/>
      </v:required>
      <v:condition test="StartingFrom.Date >= DateTime.Today" when="StartingFrom.Date != DateTime.MinValue">
        <v:message id="error.departureDate.inThePast" providers="departureDateErrors, validationSummary"/>
      </v:condition>
    </v:group>

    <v:group id="returnDateValidator" when="Mode == 'RoundTrip'">
      <v:required test="ReturningFrom.Date">
        <v:message id="error.returnDate.required" providers="returnDateErrors, validationSummary"/>
      </v:required>
      <v:condition test="ReturningFrom.Date >= StartingFrom.Date" when="ReturningFrom.Date != DateTime.MinValue">
        <v:message id="error.returnDate.beforeDeparture" providers="returnDateErrors, validationSummary"/>
      </v:condition>
    </v:group>

  </v:group>

</objects>
