{"id":18774305,"url":"https://github.com/leny/dyagram","last_synced_at":"2026-02-18T03:38:17.371Z","repository":{"id":72964254,"uuid":"50735898","full_name":"leny/dyagram","owner":"leny","description":"Micro validation schema for javascript structures","archived":false,"fork":false,"pushed_at":"2016-02-08T09:21:53.000Z","size":1,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-27T06:43:51.098Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":null,"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/leny.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":"2016-01-30T17:29:27.000Z","updated_at":"2016-01-30T17:29:27.000Z","dependencies_parsed_at":"2023-04-28T20:47:02.310Z","dependency_job_id":null,"html_url":"https://github.com/leny/dyagram","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/leny/dyagram","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leny%2Fdyagram","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leny%2Fdyagram/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leny%2Fdyagram/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leny%2Fdyagram/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/leny","download_url":"https://codeload.github.com/leny/dyagram/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leny%2Fdyagram/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29567601,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-18T00:47:08.760Z","status":"online","status_checked_at":"2026-02-18T02:00:09.468Z","response_time":162,"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-11-07T19:37:57.258Z","updated_at":"2026-02-18T03:38:12.363Z","avatar_url":"https://github.com/leny.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# dyagram\n\n\u003e Micro validation schema for javascript structures\n\n* * *\n\n**dyagram** is a simple validation schema for javascript objects, made to be easy to learn and use.\n\n## dyagram schema\n\nA **dyagram** schema is a simple `json object`, representing the structure to validate.\n\n### Check the presence/absence of a property\n\nGive a `boolean` value to a property in schema to check for its presence (or absence) in structure, regardless of its type nor value.\n\n#### Example\n\n```javascript\n{\n    \"lastname\": true, // will check for the presence of the lastname property\n    \"age\": false // will check for the absence of the age property\n}\n```\n\n### Check the type of a property\n\nGive a `string` value to a property in schema to check its type, regardless of its value.\n\n#### Supported type\n\nThe following types are supported: `boolean`, `string`, `number`, `array`, `object`.\n\n#### Example\n\n```javascript\n{\n    \"lastname\": \"string\",\n    \"firstname\": \"string\",\n    \"age\": \"number\",\n    \"address\": \"object\",\n    \"skills\": \"array\"\n}\n```\n\n### Nested object\n\n**dyagram** schema support nesting.\n\n#### Example\n\n```javascript\n{\n    \"lastname\": \"string\",\n    \"firstname\": \"string\",\n    \"age\": \"number\",\n    \"address\": {\n        \"street\": \"string\",\n        \"number\": \"number\",\n        \"city\": \"string\",\n        \"location\": {\n            \"latitude\": \"number\",\n            \"longitude\": \"number\"\n        }\n    }\n}\n```\n\n### Check for value\n\nYou can have more control on a property by using an `array`: the _first_ value of the array define the type of the property, the following values are defined by the following rules.\n\n#### `boolean`\n\nThe second value defines the value of the property.\n\n##### Example\n\n```javascript\n{\n    \"is_happy\": [ \"boolean\", true ] // will check for the property is_happy to be a boolean with the \"true\" value\n}\n```\n\n#### `string`\n\nIf the second value is a `string`, it defines the value of the property ; if its a RegExp, it defines a pattern that the property must pass.\n\n##### Example\n\n```javascript\n{\n    \"name\": [ \"string\", \"leny\" ], // will check for the property name to be a string with the \"leny\" value\n    \"zip_code\": [ \"string\", /[a-zA-Z0-9]*/ ] // will check for the property zip_code to be a string with a value passing the given regexp\n}\n```\n\n#### `number`\n\nIf the second value is a `number`, it define the value of the property ; if there's a third value, the two are used to define a valid range for the property's value.\n\n##### Example\n\n```javascript\n{\n    \"age\": [ \"number\", 30 ], // will check for the property age to be a number with 30 as value\n    \"screens\": [ \"number\", 1, 3 ] // will check for the property screens to be a number with a value between 1 \u0026 3\n}\n```\n\n_TO BE CONTINUED_\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fleny%2Fdyagram","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fleny%2Fdyagram","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fleny%2Fdyagram/lists"}