{"action":"created","issue":{"url":"https://api.github.com/repos/adzap/validates_timeliness/issues/125","labels_url":"https://api.github.com/repos/adzap/validates_timeliness/issues/125/labels{/name}","comments_url":"https://api.github.com/repos/adzap/validates_timeliness/issues/125/comments","events_url":"https://api.github.com/repos/adzap/validates_timeliness/issues/125/events","html_url":"https://github.com/adzap/validates_timeliness/issues/125","id":73046112,"number":125,"title":"Using option :format method timeliness_type_cast_code ignores given :format","user":{"login":"phlegx","id":111506,"avatar_url":"https://avatars.githubusercontent.com/u/111506?v=3","gravatar_id":"","url":"https://api.github.com/users/phlegx","html_url":"https://github.com/phlegx","followers_url":"https://api.github.com/users/phlegx/followers","following_url":"https://api.github.com/users/phlegx/following{/other_user}","gists_url":"https://api.github.com/users/phlegx/gists{/gist_id}","starred_url":"https://api.github.com/users/phlegx/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/phlegx/subscriptions","organizations_url":"https://api.github.com/users/phlegx/orgs","repos_url":"https://api.github.com/users/phlegx/repos","events_url":"https://api.github.com/users/phlegx/events{/privacy}","received_events_url":"https://api.github.com/users/phlegx/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-05-04T15:11:45Z","updated_at":"2015-09-24T23:31:10Z","closed_at":"2015-09-24T23:31:10Z","body":"Using the following validation:\r\n\r\n```ruby\r\nvalidates :published_at, presence: true, timeliness: { type: :datetime, format: 'dd.mm.yyyy, hh:nn' }\r\n```\r\n\r\nThe validation returns an error that the attribute must be set. This is caused by the method ```timeliness_type_cast_code(attr_name, var_name)``` in file https://github.com/johncarney/validates_timeliness/blob/master/lib/validates_timeliness/attribute_methods.rb#L65\r\n\r\nThe ```Timeliness::Parser.parse()``` call ignores the ```:format``` option set in the validation.\r\n\r\n```ruby\r\n\"#{var_name} = Timeliness::Parser.parse(#{var_name}, :#{type}, :zone => #{timezone.inspect})\"\r\n```\r\n\r\n**Any idea how t add ```:format``` option dynamically to ```Timeliness::Parser.parse()```?!**"},"comment":{"url":"https://api.github.com/repos/adzap/validates_timeliness/issues/comments/143079384","html_url":"https://github.com/adzap/validates_timeliness/issues/125#issuecomment-143079384","issue_url":"https://api.github.com/repos/adzap/validates_timeliness/issues/125","id":143079384,"user":{"login":"adzap","id":6318,"avatar_url":"https://avatars.githubusercontent.com/u/6318?v=3","gravatar_id":"","url":"https://api.github.com/users/adzap","html_url":"https://github.com/adzap","followers_url":"https://api.github.com/users/adzap/followers","following_url":"https://api.github.com/users/adzap/following{/other_user}","gists_url":"https://api.github.com/users/adzap/gists{/gist_id}","starred_url":"https://api.github.com/users/adzap/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/adzap/subscriptions","organizations_url":"https://api.github.com/users/adzap/orgs","repos_url":"https://api.github.com/users/adzap/repos","events_url":"https://api.github.com/users/adzap/events{/privacy}","received_events_url":"https://api.github.com/users/adzap/received_events","type":"User","site_admin":false},"created_at":"2015-09-24T23:31:10Z","updated_at":"2015-09-24T23:31:10Z","body":"Yep you got it. Type casting and validation are not the same thing. Typecasting should any valid value. The validation should block the valid acceptance of a value for more specific reasons e.g. in comparison to another value or, in your case a specific format."}}