code: def validate_dates(prop, value, xpath_map=None):
      if value is not None:
          validate_type(prop, value, dict)
          date_keys = set(value)
          if date_keys:
              if DATE_TYPE not in date_keys or DATE_VALUES not in date_keys:
                  if prop in _complex_definitions:
                      complex_keys = _complex_definitions[prop]
                  else:
                      complex_keys = _complex_definitions[DATES] if xpath_map is None else xpath_map
                  _validation_error(prop, None, value, ('keys: {0}'.format(','.join(complex_keys))))
              date_type = value[DATE_TYPE]
              if date_type not in DATE_TYPES:
                  _validation_error('dates.type', None, date_type, DATE_TYPES)
              date_vals = value[DATE_VALUES]
              validate_type('dates.values', date_vals, list)
              dates_len = len(date_vals)
              if date_type == DATE_TYPE_MISSING and dates_len != 0:
                  _validation_error('len(dates.values)', None, dates_len, 0)
              if date_type == DATE_TYPE_SINGLE and dates_len != 1:
                  _validation_error('len(dates.values)', None, dates_len, 1)
              if date_type == DATE_TYPE_RANGE and dates_len != 2:
                  _validation_error('len(dates.values)', None, dates_len, 2)
              if date_type == DATE_TYPE_MULTIPLE and dates_len < 2:
                  _validation_error('len(dates.values)', None, dates_len, 'at least two')
              for idx, date in enumerate(date_vals):
                  date_key = 'dates.value[' + str(idx) + ']'
                  validate_type(date_key, date, string_types)