{"id":21972801,"url":"https://github.com/agustinsrg/javascript-object-sanitizer","last_synced_at":"2026-03-08T10:31:37.652Z","repository":{"id":57099114,"uuid":"378109410","full_name":"AgustinSRG/javascript-object-sanitizer","owner":"AgustinSRG","description":"Object sanitizer for javascript and typescript.","archived":false,"fork":false,"pushed_at":"2024-10-02T14:43:53.000Z","size":826,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-07-06T16:55:17.143Z","etag":null,"topics":["javascript","json","object","sanitizer","schema"],"latest_commit_sha":null,"homepage":"https://agustinsrg.github.io/javascript-object-sanitizer/","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/AgustinSRG.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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-06-18T10:05:58.000Z","updated_at":"2025-04-27T08:33:06.000Z","dependencies_parsed_at":"2024-06-29T10:50:17.509Z","dependency_job_id":"d6716d81-eec1-49df-82eb-5b64bddad483","html_url":"https://github.com/AgustinSRG/javascript-object-sanitizer","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/AgustinSRG/javascript-object-sanitizer","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AgustinSRG%2Fjavascript-object-sanitizer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AgustinSRG%2Fjavascript-object-sanitizer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AgustinSRG%2Fjavascript-object-sanitizer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AgustinSRG%2Fjavascript-object-sanitizer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/AgustinSRG","download_url":"https://codeload.github.com/AgustinSRG/javascript-object-sanitizer/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AgustinSRG%2Fjavascript-object-sanitizer/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265483633,"owners_count":23774246,"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":["javascript","json","object","sanitizer","schema"],"created_at":"2024-11-29T15:21:20.391Z","updated_at":"2026-03-08T10:31:37.611Z","avatar_url":"https://github.com/AgustinSRG.png","language":"TypeScript","readme":"# Javascript Object Sanitizer\n\n[![npm version](https://badge.fury.io/js/%40asanrom%2Fjavascript-object-sanitizer.svg)](https://badge.fury.io/js/%40asanrom%2Fjavascript-object-sanitizer)\n\nObject sanitizer for javascript and typescript.\n\nForces the input to follow a pre-defined schema. Useful to check `application/json` bodies in web requests and responses from untrusted APIs.\n\n## Installation\n\nIf you are using a npm managed project use:\n\n```\nnpm install @asanrom/javascript-object-sanitizer\n```\n\nIf you are using it in the browser, download the minified file from the [Releases](https://github.com/AgustinSRG/javascript-object-sanitizer/tags) section and import it to your html:\n\n```html\n\u003cscript type=\"text/javascript\" src=\"/path/to/javascript-object-sanitizer.js\"\u003e\u003c/script\u003e\n```\n\n## Usage\n\nNode:\n\n```ts\nimport { ObjectSchema } from '@asanrom/javascript-object-sanitizer';\n\n// With require: const ObjectSchema = require('@asanrom/javascript-object-sanitizer').ObjectSchema;\n\n// Example schema or complex object\nconst schema = ObjectSchema.object({\n    stringProperty: ObjectSchema.string().withDefaultValue(\"\"),\n    integerProperty: ObjectSchema.integer(),\n    positiveNumber: ObjectSchema.number().withMin(0),\n    array: ObjectSchema.array(ObjectSchema.object({\n        arrayItemProp1: ObjectSchema.boolean(),\n    })),\n    optionalProperty: ObjectSchema.optional(ObjectSchema.number()),\n});\n\n// Test user input\nschema.test(userInput); // Returns true or false\n\n// Sanitize\nconst sanitized = schema.sanitize(userInput); // Forces user input to follow the schema\n```\n\nBrowser:\n\n```js\nwindow.ObjectSchema = ObjectSanitizer.ObjectSchema;\n\n// Example schema or complex object\nconst schema = ObjectSchema.object({\n    stringProperty: ObjectSchema.string().withDefaultValue(\"\"),\n    integerProperty: ObjectSchema.integer(),\n    positiveNumber: ObjectSchema.number().withMin(0),\n    array: ObjectSchema.array(ObjectSchema.object({\n        arrayItemProp1: ObjectSchema.boolean(),\n    })),\n    optionalProperty: ObjectSchema.optional(ObjectSchema.number()),\n});\n\n// Test user input\nschema.test(userInput); // Returns true or false\n\n// Sanitize\nconst sanitized = schema.sanitize(userInput); // Forces user input to follow the schema\n```\n\n## Documentation\n\n - [Library documentation (Auto-generated)](https://agustinsrg.github.io/javascript-object-sanitizer/)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fagustinsrg%2Fjavascript-object-sanitizer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fagustinsrg%2Fjavascript-object-sanitizer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fagustinsrg%2Fjavascript-object-sanitizer/lists"}