{"id":23705719,"url":"https://github.com/pouchdb/pouchdb-validation","last_synced_at":"2025-10-05T01:59:39.624Z","repository":{"id":36716485,"uuid":"41023051","full_name":"pouchdb/pouchdb-validation","owner":"pouchdb","description":"A PouchDB plug-in that allows you to re-use your CouchDB validate_doc_update functions on the client side.","archived":false,"fork":false,"pushed_at":"2020-11-02T00:58:17.000Z","size":31,"stargazers_count":10,"open_issues_count":27,"forks_count":7,"subscribers_count":10,"default_branch":"master","last_synced_at":"2025-08-28T07:50:39.639Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/pouchdb.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}},"created_at":"2015-08-19T08:43:26.000Z","updated_at":"2020-09-03T19:25:12.000Z","dependencies_parsed_at":"2022-09-01T11:41:03.144Z","dependency_job_id":null,"html_url":"https://github.com/pouchdb/pouchdb-validation","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/pouchdb/pouchdb-validation","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pouchdb%2Fpouchdb-validation","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pouchdb%2Fpouchdb-validation/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pouchdb%2Fpouchdb-validation/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pouchdb%2Fpouchdb-validation/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pouchdb","download_url":"https://codeload.github.com/pouchdb/pouchdb-validation/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pouchdb%2Fpouchdb-validation/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":277698987,"owners_count":25861807,"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-09-30T02:00:09.208Z","response_time":75,"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":[],"created_at":"2024-12-30T14:56:51.933Z","updated_at":"2025-10-05T01:59:39.606Z","avatar_url":"https://github.com/pouchdb.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"pouchdb-validation\n==================\n\n[![Build Status](https://travis-ci.org/pouchdb/pouchdb-validation.svg?branch=master)](https://travis-ci.org/pouchdb/pouchdb-validation)\n[![Dependency Status](https://david-dm.org/pouchdb/pouchdb-validation.svg)](https://david-dm.org/pouchdb/pouchdb-validation)\n[![devDependency Status](https://david-dm.org/pouchdb/pouchdb-validation/dev-status.svg)](https://david-dm.org/pouchdb/pouchdb-validation#info=devDependencies)\n\n\u003e A PouchDB plug-in that allows you to re-use your CouchDB validate_doc_update functions on the client side.\n\nA browser version is available.\n\n- [NodeJS package](https://www.npmjs.org/package/pouchdb-validation)\n- Browser object name: ``window.validation``\n\nFirst, make sure you understand how validation functions work in CouchDB. A good\nstart is [the CouchDB guide entry on validation functions](http://guide.couchdb.org/draft/validation.html).\n\nUsage\n-----\n\nFirst, you need to register the plug-in with PouchDB. That can be done using the\n``PouchDB.plugin()`` function. In NodeJS, you can just pass in the result of the\n``require()`` function. In the browser, you pass in the browser object name\ngiven above.\n\nAn example (using the list plug-in):\n\n```javascript\n//NodeJS (and Browserify)\nPouchDB.plugin(require(\"pouchdb-validation\"));\n\n//Browser - after the JavaScript file containing the plug-in has been\n//included via a script tag (or something similar).\nPouchDB.plugin(Validation);\n```\n\nAll functions have two ways of returning the output to the user. One is\na callback parameter, which should have the signature ``(err, resp)``.\nThe other is the Promise all functions return. PouchDB itself uses the\nsame system.\n\n### db.validatingPut(doc[, options[, callback]])\nExactly the same as the ``db.put`` function, but checks with all validation\nfunctions ('validate_doc_update') in all design documents of the current\ndatabase if it is ok to save ``doc``. In short, this method acts more like its\nCouchDB equivalent than the original PouchDB version does. The only thing you\nget to see of it is a few extra errors, i.e. of the 'unauthorized' or the\n'forbidden' type. It also has a few extra ``options`` (defaults are shown):\n\n- ``secObj``: e.g.:\n\n  ```javascript\n  {\n     admins: {\n        names: [],\n        roles: []\n     },\n     members: {\n        names: [],\n        roles: []\n     }\n  }\n  ```\n\n- ``userCtx``: e.g.:\n\n  ```javascript:\n  {\n     db: \"test_db\",\n     name: \"username\",\n     roles: [\n        \"_admin\"\n     ]\n  }\n  ```\n\n- ``checkHttp``: Set this to ``true`` if you want to validate HTTP database\n  documents offline too. Unnecessary for CouchDB, but handy for e.g.\n  pouchdb-express-router, which doesn't validate itself.\n\n### db.validatingPost(doc[, options[, callback]])\n\nSee the ``db.validatingPut()`` function.\n\n### db.validatingRemove(doc[, options[, callback]])\n\nSee the ``db.validatingPut()`` function.\n\n### db.validatingBulkDocs(bulkDocs[, options[, callback]])\n\nSee the ``db.validatingPut()`` function. Returns an array, like\n``db.bulkDocs()``. The ``all_or_nothing`` attribute on ``bulkDocs`` is\nunsupported. Also, the result array might not be in the same order as\nthe passed in documents.\n\n### db.validatingPutAttachment(docId, attachmentId, rev, attachment, type[, options[, callback]])\n\nSee the ``db.validatingPut()`` function. Output is the same as\n``db.putAttachment()`` (except for a few extra errors being possible.)\n\n### db.validatingRemoveAttachment(docId, attachmentId, rev[, options[, callback]])\n\nSee the ``db.validatingPut()`` function. Output is the same as\n``db.removeAttachment()`` (except for a few extra errors being possible.)\n\n### db.installValidationMethods()\n\nInstalls the validation methods on this database. In other words, the ``db.*``\nmethods are replaced by their ``db.validating*`` counterparts. This method is\nalways synchronous.\n\n**Throws**: an error if the methods are already installed.\n**Returns**: nothing\n\n### db.uninstallValidationMethods()\n\nUndoes what ``db.installValidationMethods`` did. This method is always\nsynchronous.\n\n**Throws**: an error if the methods aren't currently installed.\n**Returns**: nothing\n\nLicense\n-------\n\nApache-2.0\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpouchdb%2Fpouchdb-validation","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpouchdb%2Fpouchdb-validation","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpouchdb%2Fpouchdb-validation/lists"}