{"id":20567352,"url":"https://github.com/sombriks/node-backend-validation","last_synced_at":"2026-04-14T04:02:11.668Z","repository":{"id":247585355,"uuid":"825985180","full_name":"sombriks/node-backend-validation","owner":"sombriks","description":"Samples on how to validate user data in node","archived":false,"fork":false,"pushed_at":"2024-07-16T14:17:15.000Z","size":502,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-06T09:23:00.165Z","etag":null,"topics":["ava","joi","koa","nodejs","pglite","supertest","ts-node","tsx","typescript"],"latest_commit_sha":null,"homepage":"https://sombriks.com/blog/0072-node-backend-validation-exemplified/","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/sombriks.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":"2024-07-08T22:17:08.000Z","updated_at":"2024-07-23T06:42:41.000Z","dependencies_parsed_at":"2025-03-06T09:18:38.826Z","dependency_job_id":"5a5472fe-a5cc-498a-95b1-ad630ea10e30","html_url":"https://github.com/sombriks/node-backend-validation","commit_stats":null,"previous_names":["sombriks/node-backend-validation"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/sombriks/node-backend-validation","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sombriks%2Fnode-backend-validation","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sombriks%2Fnode-backend-validation/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sombriks%2Fnode-backend-validation/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sombriks%2Fnode-backend-validation/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sombriks","download_url":"https://codeload.github.com/sombriks/node-backend-validation/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sombriks%2Fnode-backend-validation/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278411261,"owners_count":25982368,"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","status":"online","status_checked_at":"2025-10-05T02:00:06.059Z","response_time":54,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["ava","joi","koa","nodejs","pglite","supertest","ts-node","tsx","typescript"],"created_at":"2024-11-16T04:46:26.424Z","updated_at":"2025-10-05T05:11:38.266Z","avatar_url":"https://github.com/sombriks.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# [node-backend-validation][repo]\n\n[![CI tests](https://github.com/sombriks/node-backend-validation/actions/workflows/ci.yml/badge.svg)](https://github.com/sombriks/node-backend-validation/actions/workflows/ci.yml)\n\nSamples on how to validate user data in node\n\n## Why validate input\n\nFor some of you, the question might seems absurd, but it's a valid question for\nanyone without any background, so:\n\nWhy validate data received from user or external service? Because:\n\n- No useful system can rely on random input.\n- Core principle of communication is meaning.\n- Data should be adherent to the system domain.\n- The early we validate, early we handle problems.\n- No backend service should blindly trust data received.\n\n## Samples\n\nWe showcase a few [Node.js][node] projects passing through distinct approaches\nto validation given certain constraints.\n\nAll projects offer the same REST API with a few differences regarding the\nvalidation strategy being experimented:\n\n    HTTP verb      Resource path                      Query parameters\n\n    GET,POST       /addresses                         q: string\n    GET,PUT,DELETE /addresses/{id}\n    GET            /addresses/{id}/people\n    PUT,DELETE     /addresses/{id}/people/{person_id}\n    GET,POST       /people                            q: string\n    GET,PUT,DELETE /people/{id}\n    GET            /people/{id}/phones                q: string\n    PUT,DELETE     /people/{id}/phones/{phone_id}\n\nSee each project for response codes and payload details.\n\n### [No validation at all][01]\n\nWhat if we let data hit the database freely?\nThis sample answers this question.\n\n### [Some verification of presence and type][02]\n\nThis project is meant to present the struggle of explicit validation.\n\n### [Validation frameworks][03]\n\nHere we use [joi][joi], a validation framework for node.\n\n### [Static type checking][04]\n\nIn this project we leap from javascript to [typescript][ts] and make use of\nstatic type check to help input data validation and development as well, thanks\nto type hints.\n\n## Noteworthy\n\n- There is also a [small benchmark project][05] using [k6][k6], putting the API\n  under stress test, so we can observe the consequences of each approach.\n- There is coverage for all projects, but for some unknown reason, some of them\n  report wrong line numbers, shifted by one or two.\n- Typescript gymnastics is tiresome and project tooling is passing through\n  transformation or i just got bad luck.\n\n[repo]: https://github.com/sombriks/node-backend-validation\n[node]: https://nodejs.org\n[01]: ./01-address-book-no-validate/README.md\n[02]: ./02-address-book-manual-validation/README.md\n[03]: ./03-address-book-joi/README.md\n[joi]: https://joi.dev/\n[04]: ./04-address-book-ts-node/README.md\n[ts]: https://www.typescriptlang.org/\n[05]: ./05-k6-benchmark/README.md\n[k6]: \u003chttps://k6.io/\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsombriks%2Fnode-backend-validation","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsombriks%2Fnode-backend-validation","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsombriks%2Fnode-backend-validation/lists"}