{"action":"created","issue":{"url":"https://api.github.com/repos/angular/angular.js/issues/13354","repository_url":"https://api.github.com/repos/angular/angular.js","labels_url":"https://api.github.com/repos/angular/angular.js/issues/13354/labels{/name}","comments_url":"https://api.github.com/repos/angular/angular.js/issues/13354/comments","events_url":"https://api.github.com/repos/angular/angular.js/issues/13354/events","html_url":"https://github.com/angular/angular.js/pull/13354","id":118093240,"number":13354,"title":"fix(ngRequired): set valid to false if select value is required (value is not in options)","user":{"login":"m-amr","id":6197215,"avatar_url":"https://avatars.githubusercontent.com/u/6197215?v=3","gravatar_id":"","url":"https://api.github.com/users/m-amr","html_url":"https://github.com/m-amr","followers_url":"https://api.github.com/users/m-amr/followers","following_url":"https://api.github.com/users/m-amr/following{/other_user}","gists_url":"https://api.github.com/users/m-amr/gists{/gist_id}","starred_url":"https://api.github.com/users/m-amr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/m-amr/subscriptions","organizations_url":"https://api.github.com/users/m-amr/orgs","repos_url":"https://api.github.com/users/m-amr/repos","events_url":"https://api.github.com/users/m-amr/events{/privacy}","received_events_url":"https://api.github.com/users/m-amr/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/angular/angular.js/labels/cla:%20yes","name":"cla: yes","color":"bfe5bf"},{"url":"https://api.github.com/repos/angular/angular.js/labels/component:%20forms","name":"component: forms","color":"7B947B"},{"url":"https://api.github.com/repos/angular/angular.js/labels/needs:%20work","name":"needs: work","color":"fbca04"},{"url":"https://api.github.com/repos/angular/angular.js/labels/type:%20bug","name":"type: bug","color":"000000"}],"state":"open","locked":false,"assignee":{"login":"Narretz","id":1153097,"avatar_url":"https://avatars.githubusercontent.com/u/1153097?v=3","gravatar_id":"","url":"https://api.github.com/users/Narretz","html_url":"https://github.com/Narretz","followers_url":"https://api.github.com/users/Narretz/followers","following_url":"https://api.github.com/users/Narretz/following{/other_user}","gists_url":"https://api.github.com/users/Narretz/gists{/gist_id}","starred_url":"https://api.github.com/users/Narretz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Narretz/subscriptions","organizations_url":"https://api.github.com/users/Narretz/orgs","repos_url":"https://api.github.com/users/Narretz/repos","events_url":"https://api.github.com/users/Narretz/events{/privacy}","received_events_url":"https://api.github.com/users/Narretz/received_events","type":"User","site_admin":false},"assignees":[{"login":"Narretz","id":1153097,"avatar_url":"https://avatars.githubusercontent.com/u/1153097?v=3","gravatar_id":"","url":"https://api.github.com/users/Narretz","html_url":"https://github.com/Narretz","followers_url":"https://api.github.com/users/Narretz/followers","following_url":"https://api.github.com/users/Narretz/following{/other_user}","gists_url":"https://api.github.com/users/Narretz/gists{/gist_id}","starred_url":"https://api.github.com/users/Narretz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Narretz/subscriptions","organizations_url":"https://api.github.com/users/Narretz/orgs","repos_url":"https://api.github.com/users/Narretz/repos","events_url":"https://api.github.com/users/Narretz/events{/privacy}","received_events_url":"https://api.github.com/users/Narretz/received_events","type":"User","site_admin":false}],"milestone":{"url":"https://api.github.com/repos/angular/angular.js/milestones/90","html_url":"https://github.com/angular/angular.js/milestones/1.5.x","labels_url":"https://api.github.com/repos/angular/angular.js/milestones/90/labels","id":1025270,"number":90,"title":"1.5.x","description":"","creator":{"login":"petebacondarwin","id":15655,"avatar_url":"https://avatars.githubusercontent.com/u/15655?v=3","gravatar_id":"","url":"https://api.github.com/users/petebacondarwin","html_url":"https://github.com/petebacondarwin","followers_url":"https://api.github.com/users/petebacondarwin/followers","following_url":"https://api.github.com/users/petebacondarwin/following{/other_user}","gists_url":"https://api.github.com/users/petebacondarwin/gists{/gist_id}","starred_url":"https://api.github.com/users/petebacondarwin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/petebacondarwin/subscriptions","organizations_url":"https://api.github.com/users/petebacondarwin/orgs","repos_url":"https://api.github.com/users/petebacondarwin/repos","events_url":"https://api.github.com/users/petebacondarwin/events{/privacy}","received_events_url":"https://api.github.com/users/petebacondarwin/received_events","type":"User","site_admin":false},"open_issues":99,"closed_issues":186,"state":"open","created_at":"2015-03-17T12:15:49Z","updated_at":"2016-08-09T08:32:29Z","due_on":null,"closed_at":null},"comments":11,"created_at":"2015-11-20T18:00:39Z","updated_at":"2016-08-09T16:30:46Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/angular/angular.js/pulls/13354","html_url":"https://github.com/angular/angular.js/pull/13354","diff_url":"https://github.com/angular/angular.js/pull/13354.diff","patch_url":"https://github.com/angular/angular.js/pull/13354.patch"},"body":"This pull request solve Issue 13172\r\nhttps://github.com/angular/angular.js/issues/13172\r\n\r\ni validate that the view value should be one of the select option\r\nso i overrideng ModelCtrl.$validators.required function in ngOptionsDirective\r\n\r\n    ngModelCtrl.$validators.required = function(modelValue, viewValue) {\r\n\r\n          if (!attr.required) {\r\n            return true;\r\n          } else if (ngModelCtrl.$isEmpty(viewValue)) {\r\n            return false;\r\n          }\r\n\r\n          var isValidOption = true;\r\n          var viewOptions = [];\r\n          // Get all option and add them to viewOptions array\r\n          angular.forEach(options.items, function(item) {\r\n            viewOptions.push(options.getViewValueFromOption(item));\r\n          });\r\n\r\n          // In case of multiple view model is an array so validate all view values\r\n          // if one of them doesn't match set isValidOption to false\r\n          if (multiple) {\r\n            for (var i = 0, length = viewValue.length; i < length; i++) {\r\n              if (viewOptions.indexOf(viewValue[i]) === -1) {\r\n                isValidOption = false;\r\n                 break;\r\n              }\r\n            }\r\n          } else {\r\n            if (viewOptions.indexOf(viewValue) === -1) {\r\n              isValidOption = false;\r\n            }\r\n          }\r\n\r\n          return isValidOption;\r\n        };\r\n\r\nwe have the following cases\r\n\r\n 1 - case  attr.required is false i return true\r\n \r\n 2 - case $isEmpty(viewValue) return false\r\n \r\n 3 - case is required and not empty now we need to validate that value is one of the options\r\n and in this case we have two subcases\r\n  \r\n  a - select in multiple and value is an array\r\n  we check that all the values of the array must be in of the select options to return true\r\n  \r\n  b - select is a single value so this value must be one of the select options to return true\r\n\r\ni think this will solve the problem,\r\n"},"comment":{"url":"https://api.github.com/repos/angular/angular.js/issues/comments/238610023","html_url":"https://github.com/angular/angular.js/pull/13354#issuecomment-238610023","issue_url":"https://api.github.com/repos/angular/angular.js/issues/13354","id":238610023,"user":{"login":"changus","id":1308199,"avatar_url":"https://avatars.githubusercontent.com/u/1308199?v=3","gravatar_id":"","url":"https://api.github.com/users/changus","html_url":"https://github.com/changus","followers_url":"https://api.github.com/users/changus/followers","following_url":"https://api.github.com/users/changus/following{/other_user}","gists_url":"https://api.github.com/users/changus/gists{/gist_id}","starred_url":"https://api.github.com/users/changus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/changus/subscriptions","organizations_url":"https://api.github.com/users/changus/orgs","repos_url":"https://api.github.com/users/changus/repos","events_url":"https://api.github.com/users/changus/events{/privacy}","received_events_url":"https://api.github.com/users/changus/received_events","type":"User","site_admin":false},"created_at":"2016-08-09T16:30:46Z","updated_at":"2016-08-09T16:30:46Z","body":"@Narretz Awesome, thank you!  I did find another thread:\r\nhttps://github.com/angular/angular.js/issues/13172 \r\n\r\nwith this pull request:\r\nhttps://github.com/angular/angular.js/pull/13962\r\n\r\nbut I copied those changes into my select.js and did not seem to fix the issue. \r\n\r\nThanks in advance for looking into it!\r\n"}}
{"actor":{"display_login":"changus"}}