{"id":17519868,"url":"https://github.com/maty21/jsonschema-validator-default","last_synced_at":"2026-03-15T03:39:52.717Z","repository":{"id":57213294,"uuid":"102468243","full_name":"maty21/jsonschema-validator-default","owner":"maty21","description":"validate object and if it written correctly return an objectwith its missing defaults","archived":false,"fork":false,"pushed_at":"2020-07-17T00:01:58.000Z","size":41,"stargazers_count":4,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-30T01:01:31.276Z","etag":null,"topics":["defaults","javascript","json-schema","node-js","validator"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","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/maty21.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}},"created_at":"2017-09-05T10:31:41.000Z","updated_at":"2020-10-23T02:15:49.000Z","dependencies_parsed_at":"2022-08-24T21:41:57.547Z","dependency_job_id":null,"html_url":"https://github.com/maty21/jsonschema-validator-default","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maty21%2Fjsonschema-validator-default","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maty21%2Fjsonschema-validator-default/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maty21%2Fjsonschema-validator-default/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maty21%2Fjsonschema-validator-default/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/maty21","download_url":"https://codeload.github.com/maty21/jsonschema-validator-default/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249535863,"owners_count":21287496,"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":["defaults","javascript","json-schema","node-js","validator"],"created_at":"2024-10-20T10:07:16.274Z","updated_at":"2026-03-15T03:39:52.659Z","avatar_url":"https://github.com/maty21.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"## jsonschema-validate-default\n\n[![Build Status](https://travis-ci.org/kube-HPC/jsonschema-validate-default.svg?branch=master)](https://travis-ci.org/kube-HPC/jsonschema-validate-default)\n[![Coverage Status](https://coveralls.io/repos/github/kube-HPC/jsonschema-validate-default/badge.svg?branch=master)](https://coveralls.io/github/kube-HPC/jsonschema-validate-default?branch=master)\n\njust a tiny libary based on jsonschema libary that allows you to test if your object is valid and if so to combine it with your deafults data\n\n### usage example\n\n### lazy \n```js\nconst validate = require('djsv');\n\n// create your schema\nconst json = {\n    \"type\": \"object\",\n    \"properties\": {\n        \"id\": {\n            \"type\": \"string\",\n            \"default\": \"id\",\n            \"required\": true\n        },\n        \"age\": {\n            \"default\": 30,\n            \"type\": \"integer\"\n        }\n    }\n}\n\n let validObject = validate(json,{id:\"maty\"}) // validObject.instance =\u003e {id:\"maty\",age:30}\n let validObject = validate(json,{id:\"maty\",age:20}) // validObject.instance =\u003e {id:\"maty\",age:20}\n let validObject = validate(json,{age:20}) //=\u003e {id:\"maty\",age:20} =\u003e error:{valid:false, errorDescription:\"id is required\"}\n let validObject = validate(json,{id:123456}) //=\u003e error:{valid:false, errorDescription:\"id is not a string error \"}\n```\n\n### with schema initiation before\n```js\n\nlet validateWithSchema = validate(json);\nlet obj= { id: \"12345\", info: { age: 6 } };\nconsole.log(JSON.stringify(validateWithSchema(obj).instance));\n```\n\n### ignore null option\nignorenull option allows you to set the default param in the return object although the value is defiend \n\n```js \n\nvalidateWithSchema = validate(json);\nconsole.log(JSON.stringify(validateWithSchema({ id: \"12345\", info: { age: 6, familyName: null } }).instance)) //=\u003e {\"id\":\"12345\",\"info\":{\"age\":6,\"familyName\":null}}\nconsole.log(JSON.stringify(validateWithSchema({ id: \"12345\", info: { age: 6, familyName: null } }, { ignoreNull:true }).instance)) //=\u003e{\"id\":\"12345\",\"info\":{\"age\":6,\"familyName\":\"unknown\"}}\n\n``` \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaty21%2Fjsonschema-validator-default","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmaty21%2Fjsonschema-validator-default","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaty21%2Fjsonschema-validator-default/lists"}