{"action":"created","issue":{"url":"https://api.github.com/repos/kraih/mojo/issues/812","labels_url":"https://api.github.com/repos/kraih/mojo/issues/812/labels{/name}","comments_url":"https://api.github.com/repos/kraih/mojo/issues/812/comments","events_url":"https://api.github.com/repos/kraih/mojo/issues/812/events","html_url":"https://github.com/kraih/mojo/issues/812","id":90052534,"number":812,"title":"Validation 'required' check doesn't work for file fields using multipart/form-data","user":{"login":"degeberg","id":60853,"avatar_url":"https://avatars.githubusercontent.com/u/60853?v=3","gravatar_id":"","url":"https://api.github.com/users/degeberg","html_url":"https://github.com/degeberg","followers_url":"https://api.github.com/users/degeberg/followers","following_url":"https://api.github.com/users/degeberg/following{/other_user}","gists_url":"https://api.github.com/users/degeberg/gists{/gist_id}","starred_url":"https://api.github.com/users/degeberg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/degeberg/subscriptions","organizations_url":"https://api.github.com/users/degeberg/orgs","repos_url":"https://api.github.com/users/degeberg/repos","events_url":"https://api.github.com/users/degeberg/events{/privacy}","received_events_url":"https://api.github.com/users/degeberg/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":8,"created_at":"2015-06-22T09:27:08Z","updated_at":"2015-06-23T00:06:14Z","closed_at":"2015-06-22T12:10:03Z","body":"Checking required fields using the validator does not work for file fields when enctype is multipart/form-data. The code below illustrates the problem. I would have expected the output to be \"no error\" if a file is uploaded, but it's always \"has error\" regardless of the submitted data.\r\n\r\n```perl\r\nuse Mojolicious::Lite;\r\n\r\nget '/' => 'index';\r\n\r\npost '/' => sub {\r\n  my $c = shift;\r\n\r\n  my $validation = $c->validation;\r\n  $validation->required('upload_file');\r\n\r\n  my $msg = $validation->has_error ? 'has error' : 'no error';\r\n  $c->render( text => $msg );\r\n} => 'submit_form';\r\n\r\napp->start;\r\n__DATA__\r\n\r\n@@ index.html.ep\r\n<!DOCTYPE html>\r\n<html>\r\n  <head><title>Upload test</title></head>\r\n  <body>\r\n    <h1>Without multipart/form-data</h1>\r\n    %= form_for 'submit_form', method => 'post' => begin\r\n      %= file_field 'upload_file'\r\n      %= submit_button\r\n    % end\r\n    <h1>With multipart/form-data</h1>\r\n    %= form_for 'submit_form', method => 'post', enctype => 'multipart/form-data' => begin\r\n      %= file_field 'upload_file'\r\n      %= submit_button\r\n    % end\r\n  </body>\r\n</html>\r\n```\r\n"},"comment":{"url":"https://api.github.com/repos/kraih/mojo/issues/comments/114309095","html_url":"https://github.com/kraih/mojo/issues/812#issuecomment-114309095","issue_url":"https://api.github.com/repos/kraih/mojo/issues/812","id":114309095,"user":{"login":"kraih","id":30094,"avatar_url":"https://avatars.githubusercontent.com/u/30094?v=3","gravatar_id":"","url":"https://api.github.com/users/kraih","html_url":"https://github.com/kraih","followers_url":"https://api.github.com/users/kraih/followers","following_url":"https://api.github.com/users/kraih/following{/other_user}","gists_url":"https://api.github.com/users/kraih/gists{/gist_id}","starred_url":"https://api.github.com/users/kraih/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kraih/subscriptions","organizations_url":"https://api.github.com/users/kraih/orgs","repos_url":"https://api.github.com/users/kraih/repos","events_url":"https://api.github.com/users/kraih/events{/privacy}","received_events_url":"https://api.github.com/users/kraih/received_events","type":"User","site_admin":false},"created_at":"2015-06-23T00:06:14Z","updated_at":"2015-06-23T00:06:14Z","body":"Feel free to post more complete proposals here, we can reopen the issue at any time."}}