public function validate($var) { if (is_object($var) && method_exists($var, '__toString')) { $var = (string) $var; } return parent::validate($var); }