{"action":"created","comment":{"url":"https://api.github.com/repos/anenchu/rc-spanishIdValidator/pulls/comments/27372389","id":27372389,"diff_hunk":"@@ -0,0 +1,114 @@\n+directives.directive('rcCif', [function(){\n+\treturn {\n+\t\trequire:\"ngModel\",\n+\t\n+\t link: function (scope, elm, attrs, ctrl){\n+\t\tvar validationToExecute = function (viewValue) {\n+\t\t\tvar currentTypedValue = viewValue;\n+\n+\t\t\tif(fullCIFValidation(currentTypedValue)){\n+\t\t\t\tctrl.$setValidity('cif', true);\n+\t\t\t}else{\n+\t\t\t\tctrl.$setValidity('cif', false);\n+\t\t\t}\n+\t\t};\n+\n+\t\t/*\n+        * Tiene que recibir el cif sin espacios ni guiones\n+        * Esta funcion es llamada\n+        * http://www.lawebdelprogramador.com/codigo/JavaScript/1992-Validar_un_CIF_NIF_y_DNI.html\n+        */\n+\n+        function fullCIFValidation(cif){\n+        \treturn (validateCIFSintax(cif) && validateCIFSemantic(cif));\n+        }\n+        \n+        function validateCIFSintax(cif){\n+            var cifPattern = /^[ABCDEFGHJKLMNPQRSUVW][0-9]{7}[0-9A-J]$/;\n+\n+            return cifPattern.test(cif);\n+        }\n+\n+        function validateCIFSemantic(cif)\n+        {\n+        \n+            //Quitamos el primer caracter y el ultimo digito\n+            var valueCif=cif.substr(1,cif.length-2);\n+            var sumPairs=0;\n+\n+            //Sumamos las cifras pares de la cadena\n+            for(i=1;i<valueCif.length;i=i+2)\n+            {\n+                sumPairs=sumPairs+parseInt(valueCif.substr(i,1));\n+            }\n+\n+            var sumOdd=0;\n+\n+            //Sumamos las cifras impares de la cadena\n+            for(i=0;i<valueCif.length;i=i+2)\n+            {\n+                result=parseInt(valueCif.substr(i,1))*2;\n+                if(String(result).length==1)\n+                {\n+                    // Un solo caracter\n+                    sumOdd=sumOdd+parseInt(result);\n+                }else{\n+                    // Dos caracteres. Los sumamos...\n+                    sumOdd=sumOdd+parseInt(String(result).substr(0,1))+parseInt(String(result).substr(1,1));\n+                }\n+            }\n+\n+            // Sumamos las dos sumas que hemos realizado\n+            sum=sumPairs+sumOdd;\n+\n+            var unit=String(sum).substr(1,1)\n+            unit=10-parseInt(unit);\n+\n+            var firstChar=cif.substr(0,1).toUpperCase();\n+\n+            if(firstChar.match(/^[FJKNPQRSUVW]$/))\n+            {\n+                //Empieza por .... Comparamos la ultima letra\n+                if(String.fromCharCode(64+unit).toUpperCase()==cif.substr(cif.length-1,1).toUpperCase())\n+                    return true;    \n+            }else if(firstChar.match(/^[XYZ]$/)){\n+                //Se valida como un dni\n+                    var newcif;\n+                    if(firstChar==\"X\")\n+                        newcif=cif.substr(1);\n+                    else if(firstChar==\"Y\")\n+                        newcif=\"1\"+cif.substr(1);\n+                    else if(firstChar==\"Z\")\n+                        newcif=\"2\"+cif.substr(1);\n+                    return validateDNI(newcif);\n+            }else if(firstChar.match(/^[ABCDEFGHLM]$/)){\n+                //Se revisa que el ultimo valor coincida con el calculo\n+                if(unit==10)\n+                    unit=0;\n+                if(cif.substr(cif.length-1,1)==String(unit))\n+                    return true;\n+            }else{\n+                //Se valida como un dni\n+                return validateDNI(cif);\n+            }\n+            return false;\n+        }\n+\n+        function validateDNI(dni){","path":"src/directives/rccif.js","position":97,"original_position":97,"commit_id":"e9df23a7e2e2337821fa91b85cdd10d1e103dd97","original_commit_id":"e9df23a7e2e2337821fa91b85cdd10d1e103dd97","user":{"login":"JoseAntonioRuiz","id":9025185,"avatar_url":"https://avatars.githubusercontent.com/u/9025185?v=3","gravatar_id":"","url":"https://api.github.com/users/JoseAntonioRuiz","html_url":"https://github.com/JoseAntonioRuiz","followers_url":"https://api.github.com/users/JoseAntonioRuiz/followers","following_url":"https://api.github.com/users/JoseAntonioRuiz/following{/other_user}","gists_url":"https://api.github.com/users/JoseAntonioRuiz/gists{/gist_id}","starred_url":"https://api.github.com/users/JoseAntonioRuiz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JoseAntonioRuiz/subscriptions","organizations_url":"https://api.github.com/users/JoseAntonioRuiz/orgs","repos_url":"https://api.github.com/users/JoseAntonioRuiz/repos","events_url":"https://api.github.com/users/JoseAntonioRuiz/events{/privacy}","received_events_url":"https://api.github.com/users/JoseAntonioRuiz/received_events","type":"User","site_admin":false},"body":"Ok, I'll change.","created_at":"2015-03-30T08:11:16Z","updated_at":"2015-03-30T08:11:16Z","html_url":"https://github.com/anenchu/rc-spanishIdValidator/pull/8#discussion_r27372389","pull_request_url":"https://api.github.com/repos/anenchu/rc-spanishIdValidator/pulls/8","_links":{"self":{"href":"https://api.github.com/repos/anenchu/rc-spanishIdValidator/pulls/comments/27372389"},"html":{"href":"https://github.com/anenchu/rc-spanishIdValidator/pull/8#discussion_r27372389"},"pull_request":{"href":"https://api.github.com/repos/anenchu/rc-spanishIdValidator/pulls/8"}}},"pull_request":{"url":"https://api.github.com/repos/anenchu/rc-spanishIdValidator/pulls/8","id":32006556,"html_url":"https://github.com/anenchu/rc-spanishIdValidator/pull/8","diff_url":"https://github.com/anenchu/rc-spanishIdValidator/pull/8.diff","patch_url":"https://github.com/anenchu/rc-spanishIdValidator/pull/8.patch","issue_url":"https://api.github.com/repos/anenchu/rc-spanishIdValidator/issues/8","number":8,"state":"open","locked":false,"title":"Add directive rccif.js and test files for validate cif","user":{"login":"JoseAntonioRuiz","id":9025185,"avatar_url":"https://avatars.githubusercontent.com/u/9025185?v=3","gravatar_id":"","url":"https://api.github.com/users/JoseAntonioRuiz","html_url":"https://github.com/JoseAntonioRuiz","followers_url":"https://api.github.com/users/JoseAntonioRuiz/followers","following_url":"https://api.github.com/users/JoseAntonioRuiz/following{/other_user}","gists_url":"https://api.github.com/users/JoseAntonioRuiz/gists{/gist_id}","starred_url":"https://api.github.com/users/JoseAntonioRuiz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JoseAntonioRuiz/subscriptions","organizations_url":"https://api.github.com/users/JoseAntonioRuiz/orgs","repos_url":"https://api.github.com/users/JoseAntonioRuiz/repos","events_url":"https://api.github.com/users/JoseAntonioRuiz/events{/privacy}","received_events_url":"https://api.github.com/users/JoseAntonioRuiz/received_events","type":"User","site_admin":false},"body":"Directive for validate cif number rccif.js  and unit test in karma.\r\n","created_at":"2015-03-26T10:55:05Z","updated_at":"2015-03-30T08:11:16Z","closed_at":null,"merged_at":null,"merge_commit_sha":"b4b9c6c879929af501dc082e3dbaecb400b6cade","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/anenchu/rc-spanishIdValidator/pulls/8/commits","review_comments_url":"https://api.github.com/repos/anenchu/rc-spanishIdValidator/pulls/8/comments","review_comment_url":"https://api.github.com/repos/anenchu/rc-spanishIdValidator/pulls/comments{/number}","comments_url":"https://api.github.com/repos/anenchu/rc-spanishIdValidator/issues/8/comments","statuses_url":"https://api.github.com/repos/anenchu/rc-spanishIdValidator/statuses/e9df23a7e2e2337821fa91b85cdd10d1e103dd97","head":{"label":"anenchu:16_B_Directive_CIF","ref":"16_B_Directive_CIF","sha":"e9df23a7e2e2337821fa91b85cdd10d1e103dd97","user":{"login":"anenchu","id":6853461,"avatar_url":"https://avatars.githubusercontent.com/u/6853461?v=3","gravatar_id":"","url":"https://api.github.com/users/anenchu","html_url":"https://github.com/anenchu","followers_url":"https://api.github.com/users/anenchu/followers","following_url":"https://api.github.com/users/anenchu/following{/other_user}","gists_url":"https://api.github.com/users/anenchu/gists{/gist_id}","starred_url":"https://api.github.com/users/anenchu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/anenchu/subscriptions","organizations_url":"https://api.github.com/users/anenchu/orgs","repos_url":"https://api.github.com/users/anenchu/repos","events_url":"https://api.github.com/users/anenchu/events{/privacy}","received_events_url":"https://api.github.com/users/anenchu/received_events","type":"User","site_admin":false},"repo":{"id":32088633,"name":"rc-spanishIdValidator","full_name":"anenchu/rc-spanishIdValidator","owner":{"login":"anenchu","id":6853461,"avatar_url":"https://avatars.githubusercontent.com/u/6853461?v=3","gravatar_id":"","url":"https://api.github.com/users/anenchu","html_url":"https://github.com/anenchu","followers_url":"https://api.github.com/users/anenchu/followers","following_url":"https://api.github.com/users/anenchu/following{/other_user}","gists_url":"https://api.github.com/users/anenchu/gists{/gist_id}","starred_url":"https://api.github.com/users/anenchu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/anenchu/subscriptions","organizations_url":"https://api.github.com/users/anenchu/orgs","repos_url":"https://api.github.com/users/anenchu/repos","events_url":"https://api.github.com/users/anenchu/events{/privacy}","received_events_url":"https://api.github.com/users/anenchu/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/anenchu/rc-spanishIdValidator","description":"[Work in progress] This Angular library provides directives for the validation of common Spanish official ID documents.","fork":false,"url":"https://api.github.com/repos/anenchu/rc-spanishIdValidator","forks_url":"https://api.github.com/repos/anenchu/rc-spanishIdValidator/forks","keys_url":"https://api.github.com/repos/anenchu/rc-spanishIdValidator/keys{/key_id}","collaborators_url":"https://api.github.com/repos/anenchu/rc-spanishIdValidator/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/anenchu/rc-spanishIdValidator/teams","hooks_url":"https://api.github.com/repos/anenchu/rc-spanishIdValidator/hooks","issue_events_url":"https://api.github.com/repos/anenchu/rc-spanishIdValidator/issues/events{/number}","events_url":"https://api.github.com/repos/anenchu/rc-spanishIdValidator/events","assignees_url":"https://api.github.com/repos/anenchu/rc-spanishIdValidator/assignees{/user}","branches_url":"https://api.github.com/repos/anenchu/rc-spanishIdValidator/branches{/branch}","tags_url":"https://api.github.com/repos/anenchu/rc-spanishIdValidator/tags","blobs_url":"https://api.github.com/repos/anenchu/rc-spanishIdValidator/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/anenchu/rc-spanishIdValidator/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/anenchu/rc-spanishIdValidator/git/refs{/sha}","trees_url":"https://api.github.com/repos/anenchu/rc-spanishIdValidator/git/trees{/sha}","statuses_url":"https://api.github.com/repos/anenchu/rc-spanishIdValidator/statuses/{sha}","languages_url":"https://api.github.com/repos/anenchu/rc-spanishIdValidator/languages","stargazers_url":"https://api.github.com/repos/anenchu/rc-spanishIdValidator/stargazers","contributors_url":"https://api.github.com/repos/anenchu/rc-spanishIdValidator/contributors","subscribers_url":"https://api.github.com/repos/anenchu/rc-spanishIdValidator/subscribers","subscription_url":"https://api.github.com/repos/anenchu/rc-spanishIdValidator/subscription","commits_url":"https://api.github.com/repos/anenchu/rc-spanishIdValidator/commits{/sha}","git_commits_url":"https://api.github.com/repos/anenchu/rc-spanishIdValidator/git/commits{/sha}","comments_url":"https://api.github.com/repos/anenchu/rc-spanishIdValidator/comments{/number}","issue_comment_url":"https://api.github.com/repos/anenchu/rc-spanishIdValidator/issues/comments{/number}","contents_url":"https://api.github.com/repos/anenchu/rc-spanishIdValidator/contents/{+path}","compare_url":"https://api.github.com/repos/anenchu/rc-spanishIdValidator/compare/{base}...{head}","merges_url":"https://api.github.com/repos/anenchu/rc-spanishIdValidator/merges","archive_url":"https://api.github.com/repos/anenchu/rc-spanishIdValidator/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/anenchu/rc-spanishIdValidator/downloads","issues_url":"https://api.github.com/repos/anenchu/rc-spanishIdValidator/issues{/number}","pulls_url":"https://api.github.com/repos/anenchu/rc-spanishIdValidator/pulls{/number}","milestones_url":"https://api.github.com/repos/anenchu/rc-spanishIdValidator/milestones{/number}","notifications_url":"https://api.github.com/repos/anenchu/rc-spanishIdValidator/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/anenchu/rc-spanishIdValidator/labels{/name}","releases_url":"https://api.github.com/repos/anenchu/rc-spanishIdValidator/releases{/id}","created_at":"2015-03-12T16:42:34Z","updated_at":"2015-03-30T07:38:00Z","pushed_at":"2015-03-30T07:37:59Z","git_url":"git://github.com/anenchu/rc-spanishIdValidator.git","ssh_url":"git@github.com:anenchu/rc-spanishIdValidator.git","clone_url":"https://github.com/anenchu/rc-spanishIdValidator.git","svn_url":"https://github.com/anenchu/rc-spanishIdValidator","homepage":null,"size":306,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":3,"mirror_url":null,"open_issues_count":5,"forks":3,"open_issues":5,"watchers":0,"default_branch":"master"}},"base":{"label":"anenchu:master","ref":"master","sha":"0b76c8cf97a10f24c96c65308518362d3b5ffa44","user":{"login":"anenchu","id":6853461,"avatar_url":"https://avatars.githubusercontent.com/u/6853461?v=3","gravatar_id":"","url":"https://api.github.com/users/anenchu","html_url":"https://github.com/anenchu","followers_url":"https://api.github.com/users/anenchu/followers","following_url":"https://api.github.com/users/anenchu/following{/other_user}","gists_url":"https://api.github.com/users/anenchu/gists{/gist_id}","starred_url":"https://api.github.com/users/anenchu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/anenchu/subscriptions","organizations_url":"https://api.github.com/users/anenchu/orgs","repos_url":"https://api.github.com/users/anenchu/repos","events_url":"https://api.github.com/users/anenchu/events{/privacy}","received_events_url":"https://api.github.com/users/anenchu/received_events","type":"User","site_admin":false},"repo":{"id":32088633,"name":"rc-spanishIdValidator","full_name":"anenchu/rc-spanishIdValidator","owner":{"login":"anenchu","id":6853461,"avatar_url":"https://avatars.githubusercontent.com/u/6853461?v=3","gravatar_id":"","url":"https://api.github.com/users/anenchu","html_url":"https://github.com/anenchu","followers_url":"https://api.github.com/users/anenchu/followers","following_url":"https://api.github.com/users/anenchu/following{/other_user}","gists_url":"https://api.github.com/users/anenchu/gists{/gist_id}","starred_url":"https://api.github.com/users/anenchu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/anenchu/subscriptions","organizations_url":"https://api.github.com/users/anenchu/orgs","repos_url":"https://api.github.com/users/anenchu/repos","events_url":"https://api.github.com/users/anenchu/events{/privacy}","received_events_url":"https://api.github.com/users/anenchu/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/anenchu/rc-spanishIdValidator","description":"[Work in progress] This Angular library provides directives for the validation of common Spanish official ID documents.","fork":false,"url":"https://api.github.com/repos/anenchu/rc-spanishIdValidator","forks_url":"https://api.github.com/repos/anenchu/rc-spanishIdValidator/forks","keys_url":"https://api.github.com/repos/anenchu/rc-spanishIdValidator/keys{/key_id}","collaborators_url":"https://api.github.com/repos/anenchu/rc-spanishIdValidator/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/anenchu/rc-spanishIdValidator/teams","hooks_url":"https://api.github.com/repos/anenchu/rc-spanishIdValidator/hooks","issue_events_url":"https://api.github.com/repos/anenchu/rc-spanishIdValidator/issues/events{/number}","events_url":"https://api.github.com/repos/anenchu/rc-spanishIdValidator/events","assignees_url":"https://api.github.com/repos/anenchu/rc-spanishIdValidator/assignees{/user}","branches_url":"https://api.github.com/repos/anenchu/rc-spanishIdValidator/branches{/branch}","tags_url":"https://api.github.com/repos/anenchu/rc-spanishIdValidator/tags","blobs_url":"https://api.github.com/repos/anenchu/rc-spanishIdValidator/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/anenchu/rc-spanishIdValidator/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/anenchu/rc-spanishIdValidator/git/refs{/sha}","trees_url":"https://api.github.com/repos/anenchu/rc-spanishIdValidator/git/trees{/sha}","statuses_url":"https://api.github.com/repos/anenchu/rc-spanishIdValidator/statuses/{sha}","languages_url":"https://api.github.com/repos/anenchu/rc-spanishIdValidator/languages","stargazers_url":"https://api.github.com/repos/anenchu/rc-spanishIdValidator/stargazers","contributors_url":"https://api.github.com/repos/anenchu/rc-spanishIdValidator/contributors","subscribers_url":"https://api.github.com/repos/anenchu/rc-spanishIdValidator/subscribers","subscription_url":"https://api.github.com/repos/anenchu/rc-spanishIdValidator/subscription","commits_url":"https://api.github.com/repos/anenchu/rc-spanishIdValidator/commits{/sha}","git_commits_url":"https://api.github.com/repos/anenchu/rc-spanishIdValidator/git/commits{/sha}","comments_url":"https://api.github.com/repos/anenchu/rc-spanishIdValidator/comments{/number}","issue_comment_url":"https://api.github.com/repos/anenchu/rc-spanishIdValidator/issues/comments{/number}","contents_url":"https://api.github.com/repos/anenchu/rc-spanishIdValidator/contents/{+path}","compare_url":"https://api.github.com/repos/anenchu/rc-spanishIdValidator/compare/{base}...{head}","merges_url":"https://api.github.com/repos/anenchu/rc-spanishIdValidator/merges","archive_url":"https://api.github.com/repos/anenchu/rc-spanishIdValidator/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/anenchu/rc-spanishIdValidator/downloads","issues_url":"https://api.github.com/repos/anenchu/rc-spanishIdValidator/issues{/number}","pulls_url":"https://api.github.com/repos/anenchu/rc-spanishIdValidator/pulls{/number}","milestones_url":"https://api.github.com/repos/anenchu/rc-spanishIdValidator/milestones{/number}","notifications_url":"https://api.github.com/repos/anenchu/rc-spanishIdValidator/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/anenchu/rc-spanishIdValidator/labels{/name}","releases_url":"https://api.github.com/repos/anenchu/rc-spanishIdValidator/releases{/id}","created_at":"2015-03-12T16:42:34Z","updated_at":"2015-03-30T07:38:00Z","pushed_at":"2015-03-30T07:37:59Z","git_url":"git://github.com/anenchu/rc-spanishIdValidator.git","ssh_url":"git@github.com:anenchu/rc-spanishIdValidator.git","clone_url":"https://github.com/anenchu/rc-spanishIdValidator.git","svn_url":"https://github.com/anenchu/rc-spanishIdValidator","homepage":null,"size":306,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":3,"mirror_url":null,"open_issues_count":5,"forks":3,"open_issues":5,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/anenchu/rc-spanishIdValidator/pulls/8"},"html":{"href":"https://github.com/anenchu/rc-spanishIdValidator/pull/8"},"issue":{"href":"https://api.github.com/repos/anenchu/rc-spanishIdValidator/issues/8"},"comments":{"href":"https://api.github.com/repos/anenchu/rc-spanishIdValidator/issues/8/comments"},"review_comments":{"href":"https://api.github.com/repos/anenchu/rc-spanishIdValidator/pulls/8/comments"},"review_comment":{"href":"https://api.github.com/repos/anenchu/rc-spanishIdValidator/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/anenchu/rc-spanishIdValidator/pulls/8/commits"},"statuses":{"href":"https://api.github.com/repos/anenchu/rc-spanishIdValidator/statuses/e9df23a7e2e2337821fa91b85cdd10d1e103dd97"}}}}