// This may look like C code, but it's really -*- C++ -*-
/*
 * Copyright (C) 2007 Koen Deforche, Kessel-Lo, Belgium.
 *
 * See the LICENSE file for terms of use.
 */

#ifndef WDATE_VALIDATOR_H_
#define WDATE_VALIDATOR_H_

#include <WDate>
#include <WValidator>

namespace Wt {

/*! \brief A validator for dates.
 *
 * This validator only accepts input in the dd/mm/yyyy format,
 * and checks that the date is in the right range.
 */
class WDateValidator : public WValidator
{
public:
  /*! \brief Construct a date validator.
   *
   * The validator will accept only dates in the indicated range.
   */
  WDateValidator(const WDate& bottom = WDate::NoDate,
		 const WDate& top = WDate::NoDate);

  virtual State validate(WString& input, int& pos) const;

  /*! \brief Parse a date.
   *
   * Returns WDate::NoDate when the input is invalid.
   */
  static WDate parse(const WString& input);

private:
  WDate bottom_, top_;
};

}

#endif // DATE_VALIDATOR_H_
