<?php

/**
 * User input validator
 * 
 * This is the base class for most validators.
 * 
 * The default behavior always considers user input valid.
 * Subclasses *need* to call the validate() method before
 * doing anything else, to ensure the View error is cleared
 * in case the user input is valid.
 *
 * @version DR1.6
 */
abstract class Validator implements IValidator {



	protected $value;
	protected $view;
	


	/**
	 * Constructs a Validator
	 * 
	 * @param value : the user input to be validated
	 * @param view : the View where any error shall be posted
	 */
	public function __construct($value, IReadableView $view) {
		$this->value = $value;
		$this->view = $view;
	}



	/**
	 * Validates user input
	 * 
	 * @return true (user input valid)
	 */
	public function valid() {
		// Valid by default
		$this->view->clearError();
		return true;
	}



} // Validator

?>