// validation methods ----------------------------------------------

	/** @result string error message if invalid, or null if valid
	 * If more types have to be added to the validation this method must be overridden.
	 * @param mixed $value to be validated
	 * @param boolean $validateReadOnly wheather to validate that readOnly propeties are not set
	 */
	function validate($value, $validateReadOnly=true) 
	{
		if ($validateReadOnly && $this->readOnly) 
			return $this->errorReadOnly;

		switch ($this->type) {
			case "boolean":
				return $this->validateBoolean($value);
			case "number":
				return $this->validateNumber($value);
			case "string":
				return $this->validateString($value);
			case "date":
				return $this->validateDate($value);
			case "timestamp":
				return $this->validateTimestamp($value);
			case "time":
				return $this->validateTime($value);
			case "email":
				return $this->validateEmail($value);
			case "html":
				return $this->validateString($value);
			case "currency":
				return $this->validateNumber($value);
			default:
				if (class_exists($this->type))
					return $this->validateObject($value);
					
			//can not validate values of unknown type
			return $this->errorInvalidType. $type;
		}
			
	}