{"action":"created","issue":{"url":"https://api.github.com/repos/auraphp/Aura.Filter/issues/99","labels_url":"https://api.github.com/repos/auraphp/Aura.Filter/issues/99/labels{/name}","comments_url":"https://api.github.com/repos/auraphp/Aura.Filter/issues/99/comments","events_url":"https://api.github.com/repos/auraphp/Aura.Filter/issues/99/events","html_url":"https://github.com/auraphp/Aura.Filter/issues/99","id":123567045,"number":99,"title":"getDefaultMessage() error when using a Closure and the validation fails","user":{"login":"jelofson","id":497112,"avatar_url":"https://avatars.githubusercontent.com/u/497112?v=3","gravatar_id":"","url":"https://api.github.com/users/jelofson","html_url":"https://github.com/jelofson","followers_url":"https://api.github.com/users/jelofson/followers","following_url":"https://api.github.com/users/jelofson/following{/other_user}","gists_url":"https://api.github.com/users/jelofson/gists{/gist_id}","starred_url":"https://api.github.com/users/jelofson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jelofson/subscriptions","organizations_url":"https://api.github.com/users/jelofson/orgs","repos_url":"https://api.github.com/users/jelofson/repos","events_url":"https://api.github.com/users/jelofson/events{/privacy}","received_events_url":"https://api.github.com/users/jelofson/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/auraphp/Aura.Filter/labels/bug","name":"bug","color":"fc2929"},{"url":"https://api.github.com/repos/auraphp/Aura.Filter/labels/v2","name":"v2","color":"fbca04"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2015-12-22T22:19:25Z","updated_at":"2016-01-27T16:43:50Z","closed_at":null,"body":"Try the following:\r\n\r\n```\r\n$filter = $filter_factory->newSubjectFilter();\r\n$filter->validate('age')->is('callback', function($s, $f) {\r\n    return false;\r\n});\r\n// PHP Catchable fatal error:  Object of class Closure could not be converted to string in ... \r\n// filter/src/Spec/Spec.php on line 324\r\n```\r\n\r\nSeems that there should be a check to see if args is a Closure.\r\n\r\nNOTE: if you use ```asHardRule('whatever')``` it works\r\n    \r\n```\r\n// From Spec.php line 324ish\r\nprotected function getDefaultMessage()\r\n{\r\n    $message = $this->rule;\r\n    if ($this->args) {\r\n        $message .= '(' . implode(', ', $this->args) . ')';\r\n    }\r\n    return $message;\r\n}\r\n```"},"comment":{"url":"https://api.github.com/repos/auraphp/Aura.Filter/issues/comments/175737567","html_url":"https://github.com/auraphp/Aura.Filter/issues/99#issuecomment-175737567","issue_url":"https://api.github.com/repos/auraphp/Aura.Filter/issues/99","id":175737567,"user":{"login":"harikt","id":120454,"avatar_url":"https://avatars.githubusercontent.com/u/120454?v=3","gravatar_id":"","url":"https://api.github.com/users/harikt","html_url":"https://github.com/harikt","followers_url":"https://api.github.com/users/harikt/followers","following_url":"https://api.github.com/users/harikt/following{/other_user}","gists_url":"https://api.github.com/users/harikt/gists{/gist_id}","starred_url":"https://api.github.com/users/harikt/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/harikt/subscriptions","organizations_url":"https://api.github.com/users/harikt/orgs","repos_url":"https://api.github.com/users/harikt/repos","events_url":"https://api.github.com/users/harikt/events{/privacy}","received_events_url":"https://api.github.com/users/harikt/received_events","type":"User","site_admin":false},"created_at":"2016-01-27T16:43:50Z","updated_at":"2016-01-27T16:43:50Z","body":"There is a problem in this, how can we fix this bug.\r\n\r\n1 . The `$this->args` is the one that contains closure. So one fix is check if its callable and skip the implode. \r\n2 . Check in the $this->args if it is a closure and remove it.\r\n\r\nBoth don't have a proper message to give back as failure. May be ask to add a failure message  if it is callable ?"}}