{"action":"opened","issue":{"url":"https://api.github.com/repos/ng-bootstrap/ng-bootstrap/issues/2652","repository_url":"https://api.github.com/repos/ng-bootstrap/ng-bootstrap","labels_url":"https://api.github.com/repos/ng-bootstrap/ng-bootstrap/issues/2652/labels{/name}","comments_url":"https://api.github.com/repos/ng-bootstrap/ng-bootstrap/issues/2652/comments","events_url":"https://api.github.com/repos/ng-bootstrap/ng-bootstrap/issues/2652/events","html_url":"https://github.com/ng-bootstrap/ng-bootstrap/issues/2652","id":354797291,"node_id":"MDU6SXNzdWUzNTQ3OTcyOTE=","number":2652,"title":"(proposal): Explicitly define Datepicker validation error API","user":{"login":"AbakumovAlexandr","id":6968009,"node_id":"MDQ6VXNlcjY5NjgwMDk=","avatar_url":"https://avatars0.githubusercontent.com/u/6968009?v=4","gravatar_id":"","url":"https://api.github.com/users/AbakumovAlexandr","html_url":"https://github.com/AbakumovAlexandr","followers_url":"https://api.github.com/users/AbakumovAlexandr/followers","following_url":"https://api.github.com/users/AbakumovAlexandr/following{/other_user}","gists_url":"https://api.github.com/users/AbakumovAlexandr/gists{/gist_id}","starred_url":"https://api.github.com/users/AbakumovAlexandr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AbakumovAlexandr/subscriptions","organizations_url":"https://api.github.com/users/AbakumovAlexandr/orgs","repos_url":"https://api.github.com/users/AbakumovAlexandr/repos","events_url":"https://api.github.com/users/AbakumovAlexandr/events{/privacy}","received_events_url":"https://api.github.com/users/AbakumovAlexandr/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-08-28T15:58:07Z","updated_at":"2018-08-28T15:58:07Z","closed_at":null,"author_association":"NONE","body":"### Feature description:\r\nRight now the only way to know how to handle `Datepicker`'s validation errors is to investigate [this method](https://github.com/ng-bootstrap/ng-bootstrap/blob/86f1283a3d9e3f8d543ed833e93f83014035bb78/src/datepicker/datepicker-input.ts#L211):\r\n```\r\n  validate(c: AbstractControl): {[key: string]: any} {\r\n    const value = c.value;\r\n\r\n    if (value === null || value === undefined) {\r\n      return null;\r\n    }\r\n\r\n    const ngbDate = this._fromDateStruct(this._dateAdapter.fromModel(value));\r\n\r\n    if (!this._calendar.isValid(ngbDate)) {\r\n      return {'ngbDate': {invalid: c.value}};\r\n    }\r\n\r\n    if (this.minDate && ngbDate.before(NgbDate.from(this.minDate))) {\r\n      return {'ngbDate': {requiredBefore: this.minDate}};\r\n    }\r\n\r\n    if (this.maxDate && ngbDate.after(NgbDate.from(this.maxDate))) {\r\n      return {'ngbDate': {requiredAfter: this.maxDate}};\r\n    }\r\n}\r\n```\r\n\r\nAlso, there seems to be no docs on it. So, consumers are not exactly sure if it supposed to be a public API and that it's safe to rely on this shape of error object:\r\n```\r\n{\r\n    ngbDate: {\r\n        invalid?: string,\r\n        requiredBefore?: NgbDateStruct,\r\n        requiredAfter?: NgbDateStruct,\r\n    }\r\n}\r\n```\r\nDefining this (or similar) type of validation error explicitly and adding it to a public API and/or to docs would resolve this uncertainty.\r\n\r\n### Version of ng-bootstrap:\r\n\r\nng-bootstrap: 3.1.0"}}
{"actor":{"display_login":"AbakumovAlexandr"}}