{"action":"created","issue":{"url":"https://api.github.com/repos/angular/angular/issues/10150","repository_url":"https://api.github.com/repos/angular/angular","labels_url":"https://api.github.com/repos/angular/angular/issues/10150/labels{/name}","comments_url":"https://api.github.com/repos/angular/angular/issues/10150/comments","events_url":"https://api.github.com/repos/angular/angular/issues/10150/events","html_url":"https://github.com/angular/angular/issues/10150","id":166214926,"number":10150,"title":"Validator.pattern should accept a Regular Expression instead of a String","user":{"login":"batchu","id":4350280,"avatar_url":"https://avatars.githubusercontent.com/u/4350280?v=3","gravatar_id":"","url":"https://api.github.com/users/batchu","html_url":"https://github.com/batchu","followers_url":"https://api.github.com/users/batchu/followers","following_url":"https://api.github.com/users/batchu/following{/other_user}","gists_url":"https://api.github.com/users/batchu/gists{/gist_id}","starred_url":"https://api.github.com/users/batchu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/batchu/subscriptions","organizations_url":"https://api.github.com/users/batchu/orgs","repos_url":"https://api.github.com/users/batchu/repos","events_url":"https://api.github.com/users/batchu/events{/privacy}","received_events_url":"https://api.github.com/users/batchu/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/angular/angular/labels/comp:%20forms","name":"comp: forms","color":"c5def5"}],"state":"open","locked":false,"assignee":{"login":"kara","id":3871688,"avatar_url":"https://avatars.githubusercontent.com/u/3871688?v=3","gravatar_id":"","url":"https://api.github.com/users/kara","html_url":"https://github.com/kara","followers_url":"https://api.github.com/users/kara/followers","following_url":"https://api.github.com/users/kara/following{/other_user}","gists_url":"https://api.github.com/users/kara/gists{/gist_id}","starred_url":"https://api.github.com/users/kara/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kara/subscriptions","organizations_url":"https://api.github.com/users/kara/orgs","repos_url":"https://api.github.com/users/kara/repos","events_url":"https://api.github.com/users/kara/events{/privacy}","received_events_url":"https://api.github.com/users/kara/received_events","type":"User","site_admin":false},"assignees":[{"login":"kara","id":3871688,"avatar_url":"https://avatars.githubusercontent.com/u/3871688?v=3","gravatar_id":"","url":"https://api.github.com/users/kara","html_url":"https://github.com/kara","followers_url":"https://api.github.com/users/kara/followers","following_url":"https://api.github.com/users/kara/following{/other_user}","gists_url":"https://api.github.com/users/kara/gists{/gist_id}","starred_url":"https://api.github.com/users/kara/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kara/subscriptions","organizations_url":"https://api.github.com/users/kara/orgs","repos_url":"https://api.github.com/users/kara/repos","events_url":"https://api.github.com/users/kara/events{/privacy}","received_events_url":"https://api.github.com/users/kara/received_events","type":"User","site_admin":false}],"milestone":null,"comments":3,"created_at":"2016-07-18T23:15:27Z","updated_at":"2016-09-15T19:12:52Z","closed_at":null,"body":"**I'm submitting a ...**  (check one with \"x\")\r\n```\r\n[* ] bug report\r\n[ ] feature request\r\n[ ] support request => Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question\r\n```\r\n\r\n**Current behavior**\r\nHere's how I'm building a form input field\r\nRegular expression pattern:\r\n regexPattern:string  is \"/^\\d{2}\\/\\d{2}\\/\\d{4}$/\"\r\n\r\ngroup[question.key] = ['', Validators.compose([Validators.required,Validators.pattern(regexPattern)])];\r\nFormBuilder.group(group)\r\n\r\nDuring Debugging I see:\r\nregexPattern : \"/^d{2}/d{2}/d{4}$/\"\r\n{ \"pattern\": { \"requiredPattern\": \"^/^d{2}/d{2}/d{4}$/$\", \"actualValue\": \"01/01/2001\" } }\r\n\r\n\r\n**Expected/desired behavior**\r\nAs you can see the requiredPattern adds an extra ^ at the beginning and a $ at the end. Validators.pattern(String) should accept a Regexp not a String. The regexPattern set was \"/^\\d{2}\\/\\d{2}\\/\\d{4}$/\" but as you can see it's value while debugging is obvsiously requiredPattern\": \"^/^d{2}/d{2}/d{4}$/$\"\r\n\r\nValidators.patterns(String) should instead accept a regular expression literal Validators.pattern(RegExp). It should have  the same input signature as str.match(regexp) in javascript https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/match\r\n\r\n\r\n**Reproduction of the problem**\r\nIf the current behavior is a bug or you can illustrate your feature request better with an example, please provide the steps to reproduce and if possible a minimal demo of the problem via https://plnkr.co or similar (you can use this template as a starting point: http://plnkr.co/edit/tpl:AvJOMERrnz94ekVua0u5).\r\n\r\n\r\n\r\n**What is the expected behavior?**\r\n\r\n\r\n\r\n**What is the motivation / use case for changing the behavior?**\r\n\r\n\r\n\r\n**Please tell us about your environment:**\r\n\r\n* **Angular version:** 2.0.0-rc.4\r\n \r\n* **Browser:** [all | Chrome XX | Firefox XX | IE XX | Safari XX | Mobile Chrome XX | Android X.X Web Browser | iOS XX Safari | iOS XX UIWebView | iOS XX WKWebView ] \r\n \r\n* **Language:** [TypeScript X.X] \r\n"},"comment":{"url":"https://api.github.com/repos/angular/angular/issues/comments/247423596","html_url":"https://github.com/angular/angular/issues/10150#issuecomment-247423596","issue_url":"https://api.github.com/repos/angular/angular/issues/10150","id":247423596,"user":{"login":"balteo","id":922340,"avatar_url":"https://avatars.githubusercontent.com/u/922340?v=3","gravatar_id":"","url":"https://api.github.com/users/balteo","html_url":"https://github.com/balteo","followers_url":"https://api.github.com/users/balteo/followers","following_url":"https://api.github.com/users/balteo/following{/other_user}","gists_url":"https://api.github.com/users/balteo/gists{/gist_id}","starred_url":"https://api.github.com/users/balteo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/balteo/subscriptions","organizations_url":"https://api.github.com/users/balteo/orgs","repos_url":"https://api.github.com/users/balteo/repos","events_url":"https://api.github.com/users/balteo/events{/privacy}","received_events_url":"https://api.github.com/users/balteo/received_events","type":"User","site_admin":false},"created_at":"2016-09-15T19:12:52Z","updated_at":"2016-09-15T19:12:52Z","body":"What is the status of this issue? It would be nice to be able to accept a regex instead of a string..."}}
{"actor":{"display_login":"balteo"}}