{"action":"created","issue":{"url":"https://api.github.com/repos/davidkpiano/react-redux-form/issues/572","repository_url":"https://api.github.com/repos/davidkpiano/react-redux-form","labels_url":"https://api.github.com/repos/davidkpiano/react-redux-form/issues/572/labels{/name}","comments_url":"https://api.github.com/repos/davidkpiano/react-redux-form/issues/572/comments","events_url":"https://api.github.com/repos/davidkpiano/react-redux-form/issues/572/events","html_url":"https://github.com/davidkpiano/react-redux-form/issues/572","id":195131900,"number":572,"title":"Form validation function","user":{"login":"sl33kr","id":1491080,"avatar_url":"https://avatars.githubusercontent.com/u/1491080?v=3","gravatar_id":"","url":"https://api.github.com/users/sl33kr","html_url":"https://github.com/sl33kr","followers_url":"https://api.github.com/users/sl33kr/followers","following_url":"https://api.github.com/users/sl33kr/following{/other_user}","gists_url":"https://api.github.com/users/sl33kr/gists{/gist_id}","starred_url":"https://api.github.com/users/sl33kr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sl33kr/subscriptions","organizations_url":"https://api.github.com/users/sl33kr/orgs","repos_url":"https://api.github.com/users/sl33kr/repos","events_url":"https://api.github.com/users/sl33kr/events{/privacy}","received_events_url":"https://api.github.com/users/sl33kr/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2016-12-13T01:05:50Z","updated_at":"2016-12-16T13:33:08Z","closed_at":null,"body":"Hi @davidkpiano ,\r\nI have done some work to get the form validation as a function somewhat working.\r\n\r\nI was just wondering if you would like me to open a pull request for you to look at to see if it's something you are either currently working on or interested in.\r\n\r\nThe branch is here https://github.com/sl33kr/react-redux-form/tree/form_validation_function\r\n\r\nIt's rough at the moment but works for my case.\r\n\r\nIt isn't using invertValidators at the moment either.\r\n\r\nUsage is\r\n```\r\nexport function validateForm(model) {\r\n    const cust = model && model.customers[0];\r\n\r\n    if (cust && (required(cust.phoneNumber) || required(cust.email))) {\r\n        return false;\r\n    }\r\n\r\n    return {\r\n        'customers[0].phoneNumber': { 'hasPhoneOrEmail': true },\r\n        'customers[0].email': { 'hasPhoneOrEmail': true }\r\n    };\r\n}\r\n\r\n<Form model=\"appState.enquiry\" validators={validateForm}>\r\n\t<div className=\"row\">\r\n\t\t<div className=\"col-lg-6 with-icon\">\r\n\t\t\t<Errors model=\".customers[0].phoneNumber\" \r\n\t\t\t\t\tmessages={{ hasPhoneOrEmail: 'Please enter either a phone number or email.' }} />\r\n\t\t\t<Control.text model=\".customers[0].phoneNumber\" id=\"new-customer-phone\" />\r\n\t\t\t<label htmlFor=\"new-customer-phone\">Phone number *</label>\r\n\t\t</div>\r\n\t\t<div className=\"col-lg-6 with-icon\">\r\n\t\t\t<Errors model=\".customers[0].email\" \r\n\t\t\t\t\tmessages={{ typeMismatch: \"Please enter a valid email.\", hasPhoneOrEmail: 'Please enter either a phone number or email.' }} />\r\n\t\t\t<Control model=\".customers[0].email\" id=\"new-customer-email\" />\r\n\t\t\t<label htmlFor=\"new-customer-email\" className=\"\">Email</label>\r\n\t\t</div>\r\n\t</div>\r\n</Form>"},"comment":{"url":"https://api.github.com/repos/davidkpiano/react-redux-form/issues/comments/267594823","html_url":"https://github.com/davidkpiano/react-redux-form/issues/572#issuecomment-267594823","issue_url":"https://api.github.com/repos/davidkpiano/react-redux-form/issues/572","id":267594823,"user":{"login":"davidkpiano","id":1093738,"avatar_url":"https://avatars.githubusercontent.com/u/1093738?v=3","gravatar_id":"","url":"https://api.github.com/users/davidkpiano","html_url":"https://github.com/davidkpiano","followers_url":"https://api.github.com/users/davidkpiano/followers","following_url":"https://api.github.com/users/davidkpiano/following{/other_user}","gists_url":"https://api.github.com/users/davidkpiano/gists{/gist_id}","starred_url":"https://api.github.com/users/davidkpiano/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/davidkpiano/subscriptions","organizations_url":"https://api.github.com/users/davidkpiano/orgs","repos_url":"https://api.github.com/users/davidkpiano/repos","events_url":"https://api.github.com/users/davidkpiano/events{/privacy}","received_events_url":"https://api.github.com/users/davidkpiano/received_events","type":"User","site_admin":false},"created_at":"2016-12-16T13:33:08Z","updated_at":"2016-12-16T13:33:08Z","body":"Hey @sl33kr, taking a look at it now! Sorry for the delay."}}
{"actor":{"display_login":"davidkpiano"}}