{"id":31831210,"url":"https://github.com/livingdocsio/jscheme","last_synced_at":"2025-10-28T19:47:49.215Z","repository":{"id":22637912,"uuid":"25980724","full_name":"livingdocsIO/jscheme","owner":"livingdocsIO","description":"A small and simple object schema library for the browser and node","archived":false,"fork":false,"pushed_at":"2023-12-15T20:22:58.000Z","size":42,"stargazers_count":6,"open_issues_count":5,"forks_count":1,"subscribers_count":17,"default_branch":"master","last_synced_at":"2025-10-19T05:03:04.046Z","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":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/livingdocsIO.png","metadata":{"files":{"readme":"README.md","changelog":"Changelog.md","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":"2014-10-30T16:55:53.000Z","updated_at":"2018-07-19T23:51:16.000Z","dependencies_parsed_at":"2023-12-15T22:00:11.936Z","dependency_job_id":null,"html_url":"https://github.com/livingdocsIO/jscheme","commit_stats":null,"previous_names":["upfrontio/jscheme"],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/livingdocsIO/jscheme","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/livingdocsIO%2Fjscheme","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/livingdocsIO%2Fjscheme/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/livingdocsIO%2Fjscheme/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/livingdocsIO%2Fjscheme/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/livingdocsIO","download_url":"https://codeload.github.com/livingdocsIO/jscheme/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/livingdocsIO%2Fjscheme/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":281504335,"owners_count":26512865,"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-28T02:00:06.022Z","response_time":60,"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":"2025-10-11T21:48:04.344Z","updated_at":"2025-10-28T19:47:49.211Z","avatar_url":"https://github.com/livingdocsIO.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# jScheme\n\nA small and simple object schema library for the browser and node. \nIt has no dependencies and comes in under 3KB compressed and gzipped.\n\n### Basic Usage\n\nHere is a most simple example to validate an object with one property which has to be a string:\n\n```javascript\n// Add a schema.\njScheme.add('person', {\n    name: 'string'\n}); \n\n// Validate a valid object against our first schema.\njScheme.validate('person', {\n    name: 'Popeye'\n});\n\n// Let's see what happens if we check with an empty object.\njScheme.validate('person', {}); // false\njScheme.hasErrors(); // true\njScheme.getErrorMessages(); // ['person.name: required property missing']\n```\n\n### Validators\n\nYou can add one or more validators to a property in a comma-separated validation string:\n\nLike this: `property: 'boolean, optional'`\n\n\n#### Predefined Validators\n\nFor your convenience there are a few predefined validators:\n\n - `string`\n - `boolean`\n - `number`\n - `function`\n - `array`\n - `date`\n - `regexp`\n - `object`\n - `falsy`\n - `truthy`\n - `not empty`  \n   In fact the same as 'truthy' but it reads nicer, doesn't it?\n\n\n#### Special Validators\n\n - `array of {{ validator }}`  \n   E.g. 'array of string'\n - `optional`  \n   By default all propoerties you specify are required. With this you can mark one as optional.\n - `required`  \n   If you set the configuration `propertiesRequired` to `false` you can use this validator to mark a property as required.\n\n\n#### Special Properties\n\n - `__validate`  \n   Adds a validation to the parent property.\n - `__additionalProperty`  \n   Here you can define a method that will be called for every unspecified additional property. The methods signature looks like this: `function(key, value) { return false }`.\n\n\n### A more complex example\n\n```javascript\n// Let's try a more feisty schema\njScheme.add('person', {\n    name: 'string'\n    specialPowers:\n        __additionalProperty: function(key, value) { return jScheme.validate('power', value) }\n    relationshipStatus: 'relationship status'\n    archenemies: 'array of villain, optional'\n}); \n\n// Add another schema that can be nested in the first one\njScheme.add('villain', {\n    name: 'string'\n    dislikes: 'array of string'\n});\n\njScheme.add('power', {\n    hurts: 'boolean'\n    hurtsMuch: 'boolean, optional'\n});\n\n// Add a custom validator for the relationship status\njScheme.add('relationship status', function(value) {\n    return /it\\'s (complicated|relaxed|depressing)/.test(value)\n});\n\njScheme.validate('person', {\n   name: 'Peter Pan'\n   specialPowers:\n     'nagging':  { hurts: true }\n    relationshipStatus: \"it's complicated\"\n    archenemies: [\n        { name: 'John', dislikes: ['baby seals'] },\n        { name: 'Mary', dislikes: ['fun', 'flirting'] }\n    ]\n});\n```\n\n\n### Add your own Validators\n\nYou can add your own validators. They are treated just the same as the predefined ones. Also there is no difference if you add a schema or a validator in the way you define them in a validation string. The name of your validator can contain whitespaces so it is easier to read.\n\n```javascript\njScheme.add('your validator', function(value) {\n    return true || false\n});\n```\n\n### Configuration\n\n```javascript\njScheme.configure({ \n  allowAdditionalProperties: true\n  propertiesRequired: true\n});\n```\n\n**allowAdditionalProperties (default: true)**  \nObjects are allowed to have other properties than the ones specified.\n\n**propertiesRequired (default: true)**  \nThe properties added in the schemas are required by default. If you want to make a property optional you can use the validator `optional`. If this configuration is set to false all properties will be optional by default and you can mark them as required with the validatior `required`.\n\n\n## License\n\njScheme is licensed under the [MIT License](LICENSE).\n\nIn Short:\n\n- You can use, copy and modify the software however you want.\n- You can give the software away for free or sell it.\n- The only restriction is that it be accompanied by the license agreement.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flivingdocsio%2Fjscheme","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flivingdocsio%2Fjscheme","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flivingdocsio%2Fjscheme/lists"}