// 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 ($value, $validateReadOnly=true)
{
if ($validateReadOnly && $this->readOnly)
return $this->errorReadOnly;
switch ($this->type) {
case "boolean":
return $this->($value);
case "number":
return $this->($value);
case "string":
return $this->($value);
case "date":
return $this->($value);
case "timestamp":
return $this->($value);
case "time":
return $this->($value);
case "email":
return $this->($value);
case "html":
return $this->($value);
case "currency":
return $this->($value);
default:
if (class_exists($this->type))
return $this->($value);
//can not validate values of unknown type
return $this->errorInvalidType. $type;
}
}
|