{"id":20442940,"url":"https://github.com/mrbrunelli/js-validator-example","last_synced_at":"2025-10-27T14:16:12.609Z","repository":{"id":122802383,"uuid":"359212513","full_name":"mrbrunelli/js-validator-example","owner":"mrbrunelli","description":"JavaScript Validator Example With Array.prototype.every()","archived":false,"fork":false,"pushed_at":"2021-04-18T17:45:07.000Z","size":2,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-01-15T20:54:09.144Z","etag":null,"topics":["array-prototype-every","every","javascript","validator"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mrbrunelli.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-04-18T17:39:31.000Z","updated_at":"2021-04-21T14:51:34.000Z","dependencies_parsed_at":null,"dependency_job_id":"50698d3e-3165-4b92-be16-00fbcc090c12","html_url":"https://github.com/mrbrunelli/js-validator-example","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrbrunelli%2Fjs-validator-example","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrbrunelli%2Fjs-validator-example/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrbrunelli%2Fjs-validator-example/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrbrunelli%2Fjs-validator-example/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mrbrunelli","download_url":"https://codeload.github.com/mrbrunelli/js-validator-example/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241989860,"owners_count":20053804,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["array-prototype-every","every","javascript","validator"],"created_at":"2024-11-15T09:43:30.624Z","updated_at":"2025-10-27T14:16:07.548Z","avatar_url":"https://github.com/mrbrunelli.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"## Validador Simples e Elegante com JavaScript\n#### :link: [Link do meu post no Linkedin](https://www.linkedin.com/posts/mrbrunelli_javascript-every-tipoftheday-activity-6789588317840125952-2VPM)\n\n### Como parar de fazer isso?\n:x: Caso tenha muitos campos para validar, nosso código começará a ficar ilegível. Essa lógica só poderá ser utilizada para entidades do tipo \"user\". Caso eu queira validar outro tipo de entidade, terei que repetir esse formato em outro lugar do meu sistema.\n```javascript\nconst isValidUser = (user) =\u003e {\n  if (!user.name || !user.email || !user.phone || !user.city) {\n    return false;\n  }\n}\n```\n:heavy_check_mark: Solução simples e elegante. \nNesse formato nossa função não conhece o que está validando. Você pode usá-la de forma genérica em qualquer lugar, basta passar como argumento o tipo de dado esperado e o que irá ser validado.\n```javascript\nconst expectedData = [\"name\", \"email\", \"phone\", \"city\"];\n\nconst isValidData = (expectedData, receivedData) =\u003e {\n  return expectedData.every((key) =\u003e Object.keys(receivedData).includes(key));\n};\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmrbrunelli%2Fjs-validator-example","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmrbrunelli%2Fjs-validator-example","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmrbrunelli%2Fjs-validator-example/lists"}