{"action":"created","issue":{"url":"https://api.github.com/repos/mtdowling/cron-expression/issues/77","labels_url":"https://api.github.com/repos/mtdowling/cron-expression/issues/77/labels{/name}","comments_url":"https://api.github.com/repos/mtdowling/cron-expression/issues/77/comments","events_url":"https://api.github.com/repos/mtdowling/cron-expression/issues/77/events","html_url":"https://github.com/mtdowling/cron-expression/issues/77","id":59153077,"number":77,"title":"Request: Simple validation function","user":{"login":"aensley","id":95717,"avatar_url":"https://avatars.githubusercontent.com/u/95717?v=3","gravatar_id":"","url":"https://api.github.com/users/aensley","html_url":"https://github.com/aensley","followers_url":"https://api.github.com/users/aensley/followers","following_url":"https://api.github.com/users/aensley/following{/other_user}","gists_url":"https://api.github.com/users/aensley/gists{/gist_id}","starred_url":"https://api.github.com/users/aensley/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aensley/subscriptions","organizations_url":"https://api.github.com/users/aensley/orgs","repos_url":"https://api.github.com/users/aensley/repos","events_url":"https://api.github.com/users/aensley/events{/privacy}","received_events_url":"https://api.github.com/users/aensley/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-02-26T22:14:12Z","updated_at":"2015-04-23T23:06:13Z","closed_at":"2015-04-23T23:06:13Z","body":"Thank you for this useful library. It's really great. I have a small feature request. Could you add a `validateCronExpression()` or `isValidCronExpression()` static function to `CronExpression`?\r\n\r\nThe reason I need this is that there will be situations where schedules are created programatically, and I want to make sure an invalid schedule isn't saved for later usage, causing errors on every run.\r\n\r\nRight now, I'm doing this to accomplish what I need:\r\n\r\n```php\r\ntry {\r\n\t\\Cron\\CronExpression::factory($cronExpression);\r\n} catch (\\InvalidArgumentException $e) {\r\n\tLogUtil::error('Invalid cron expression \"' . $cronExpression . '\"');\r\n\treturn false;\r\n}\r\n\r\n// $cronExpression is valid. Proceed.\r\n```\r\n\r\nIt would be nice if I could do this:\r\n\r\n```php\r\nif (!\\Cron\\CronExpression::isValidCronExpression($cronExpression)) {\r\n\tLogUtil::error('Invalid cron expression \"' . $cronExpression . '\"');\r\n\treturn false;\r\n} else {\r\n\t// $cronExpression is valid. Proceed.\r\n}\r\n```\r\n\r\nIt's a very small change as far as the code I write, but I feel like my current solution is a bit ugly and hack-ish since the underlying code might change in how invalid expressions are handled."},"comment":{"url":"https://api.github.com/repos/mtdowling/cron-expression/issues/comments/95742630","html_url":"https://github.com/mtdowling/cron-expression/issues/77#issuecomment-95742630","issue_url":"https://api.github.com/repos/mtdowling/cron-expression/issues/77","id":95742630,"user":{"login":"aensley","id":95717,"avatar_url":"https://avatars.githubusercontent.com/u/95717?v=3","gravatar_id":"","url":"https://api.github.com/users/aensley","html_url":"https://github.com/aensley","followers_url":"https://api.github.com/users/aensley/followers","following_url":"https://api.github.com/users/aensley/following{/other_user}","gists_url":"https://api.github.com/users/aensley/gists{/gist_id}","starred_url":"https://api.github.com/users/aensley/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aensley/subscriptions","organizations_url":"https://api.github.com/users/aensley/orgs","repos_url":"https://api.github.com/users/aensley/repos","events_url":"https://api.github.com/users/aensley/events{/privacy}","received_events_url":"https://api.github.com/users/aensley/received_events","type":"User","site_admin":false},"created_at":"2015-04-23T23:06:13Z","updated_at":"2015-04-23T23:06:13Z","body":"Closing since #87 was merged."}}