{"action":"created","issue":{"url":"https://api.github.com/repos/martndemus/ember-form-for/issues/134","repository_url":"https://api.github.com/repos/martndemus/ember-form-for","labels_url":"https://api.github.com/repos/martndemus/ember-form-for/issues/134/labels{/name}","comments_url":"https://api.github.com/repos/martndemus/ember-form-for/issues/134/comments","events_url":"https://api.github.com/repos/martndemus/ember-form-for/issues/134/events","html_url":"https://github.com/martndemus/ember-form-for/pull/134","id":191863528,"number":134,"title":"Feat(errors): Add control if the errors are displayed","user":{"login":"fsmanuel","id":54812,"avatar_url":"https://avatars.githubusercontent.com/u/54812?v=3","gravatar_id":"","url":"https://api.github.com/users/fsmanuel","html_url":"https://github.com/fsmanuel","followers_url":"https://api.github.com/users/fsmanuel/followers","following_url":"https://api.github.com/users/fsmanuel/following{/other_user}","gists_url":"https://api.github.com/users/fsmanuel/gists{/gist_id}","starred_url":"https://api.github.com/users/fsmanuel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fsmanuel/subscriptions","organizations_url":"https://api.github.com/users/fsmanuel/orgs","repos_url":"https://api.github.com/users/fsmanuel/repos","events_url":"https://api.github.com/users/fsmanuel/events{/privacy}","received_events_url":"https://api.github.com/users/fsmanuel/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":7,"created_at":"2016-11-27T14:12:18Z","updated_at":"2016-12-03T21:41:08Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/martndemus/ember-form-for/pulls/134","html_url":"https://github.com/martndemus/ember-form-for/pull/134","diff_url":"https://github.com/martndemus/ember-form-for/pull/134.diff","patch_url":"https://github.com/martndemus/ember-form-for/pull/134.patch"},"body":"@martndemus I run into a problem with [`ember-cp-validations`](https://github.com/offirgolan/ember-cp-validations) showing the errors before any user interactions. I looked at the example code and figured that you have to control the display of errors by yourself.\r\n\r\nThis PR enables to do so. It is backwards compatible but allows to overwrite `showErrors`.\r\n\r\nAn example would be:\r\n```js\r\n// app/components/form-field.js\r\nimport FormField from 'ember-form-for/components/form-field';\r\n\r\nconst {\r\n  computed: {\r\n    and,\r\n    notEmpty,\r\n    or\r\n  }\r\n} = Ember;\r\n\r\nexport default FormField.extend({\r\n  hasContent: notEmpty('value').readOnly(),\r\n  shouldDisplayValidations: or(\r\n    'showValidations',\r\n    'object.didValidate',\r\n    'hasContent'\r\n  ).readOnly(),\r\n\r\n  showErrors: and('hasErrors', 'shouldDisplayValidations'),\r\n\r\n  focusOut() {\r\n    this._super(...arguments);\r\n    this.set('showValidations', true);\r\n  }\r\n});\r\n```\r\n\r\nIf you like the idea I'll add a section to the readme to explain it and add this example for ember-cp-validations.\r\n\r\n/cc @offirgolan\r\n"},"comment":{"url":"https://api.github.com/repos/martndemus/ember-form-for/issues/comments/264667408","html_url":"https://github.com/martndemus/ember-form-for/pull/134#issuecomment-264667408","issue_url":"https://api.github.com/repos/martndemus/ember-form-for/issues/134","id":264667408,"user":{"login":"simonihmig","id":1325249,"avatar_url":"https://avatars.githubusercontent.com/u/1325249?v=3","gravatar_id":"","url":"https://api.github.com/users/simonihmig","html_url":"https://github.com/simonihmig","followers_url":"https://api.github.com/users/simonihmig/followers","following_url":"https://api.github.com/users/simonihmig/following{/other_user}","gists_url":"https://api.github.com/users/simonihmig/gists{/gist_id}","starred_url":"https://api.github.com/users/simonihmig/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/simonihmig/subscriptions","organizations_url":"https://api.github.com/users/simonihmig/orgs","repos_url":"https://api.github.com/users/simonihmig/repos","events_url":"https://api.github.com/users/simonihmig/events{/privacy}","received_events_url":"https://api.github.com/users/simonihmig/received_events","type":"User","site_admin":false},"created_at":"2016-12-03T21:41:08Z","updated_at":"2016-12-03T21:41:08Z","body":"As I have just recently discussed this issue with @fsmanuel at our local meetup let me also jump into this briefly...\r\n\r\nAs e-cp-v is not restricted to be used with forms (could as well be just used to validate a model before saving), it should not contain any logic regarding the use of forms. After all when being asked if an empty model which has some required fields (presence validator) is valid, the only correct answer of any validations library would be no! But that does not mean the form should display that error immediately. That should only happen when it is clear that the user has finished entering his data (like when focusing out or submitting the form). So when to show errors should be a concern of the form, not the validation library.\r\n\r\nYou can see this very logic baked into the form components of ember-bootstrap (e.g. here https://github.com/kaliber5/ember-bootstrap/blob/master/addon/components/bs-form-element.js#L621-L623), where me and @offirgolan have worked together to make the form components be agnostic of the actual validation library, but still support this use case as described above out of the box...\r\n"}}
{"actor":{"display_login":"simonihmig"}}