{"action":"closed","issue":{"url":"https://api.github.com/repos/particle-php/Validator/issues/31","labels_url":"https://api.github.com/repos/particle-php/Validator/issues/31/labels{/name}","comments_url":"https://api.github.com/repos/particle-php/Validator/issues/31/comments","events_url":"https://api.github.com/repos/particle-php/Validator/issues/31/events","html_url":"https://github.com/particle-php/Validator/issues/31","id":76365493,"number":31,"title":"DateTime rule not validating dates correctly","user":{"login":"NickBelhomme","id":312003,"avatar_url":"https://avatars.githubusercontent.com/u/312003?v=3","gravatar_id":"","url":"https://api.github.com/users/NickBelhomme","html_url":"https://github.com/NickBelhomme","followers_url":"https://api.github.com/users/NickBelhomme/followers","following_url":"https://api.github.com/users/NickBelhomme/following{/other_user}","gists_url":"https://api.github.com/users/NickBelhomme/gists{/gist_id}","starred_url":"https://api.github.com/users/NickBelhomme/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/NickBelhomme/subscriptions","organizations_url":"https://api.github.com/users/NickBelhomme/orgs","repos_url":"https://api.github.com/users/NickBelhomme/repos","events_url":"https://api.github.com/users/NickBelhomme/events{/privacy}","received_events_url":"https://api.github.com/users/NickBelhomme/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-05-14T13:49:32Z","updated_at":"2015-05-20T18:13:28Z","closed_at":"2015-05-20T18:13:28Z","body":"# Context\r\n\r\nWhen passing a format to the datetime rule, it even accepts dates which are in another format because of the default behavior of the \\DateTime implementation.\r\n\r\n# Use Case\r\n```php\r\n$validator->required('date')->datetime('Ymd');\r\n$validator->validate(['date' => '12111978']); // 12 november 1978\r\n```\r\nThe above will give true while 19 can never be a correct month, nor can 78 be a correct day.\r\n\r\nThe issue lies within this part of the code:\r\n\r\n```php\r\n$date = date_create_from_format('Ymd', '11121978');\r\nvar_dump($date);\r\n```\r\n\r\nwhich gives:\r\n```\r\nobject(DateTime)#1 (3) {\r\n  [\"date\"]=>\r\n  string(26) \"1212-09-16 06:48:11.000000\"\r\n  [\"timezone_type\"]=>\r\n  int(3)\r\n  [\"timezone\"]=>\r\n  string(10) \"US/Pacific\"\r\n}\r\n```\r\nhttps://github.com/particle-php/Validator/blob/master/src/Particle/Validator/Rule/Datetime.php#L75\r\n\r\n\r\n# Acceptance Criteria\r\nWhen issuing a validation using the datetime rule, it must adhere to the format AND also verify if the date portions are the same. This ensures that  the overflow is not used and dates such as above and \r\n31-02-2015 are considered invalid."}}