{"id":18774550,"url":"https://github.com/staab/janet-schema","last_synced_at":"2026-01-28T02:51:46.266Z","repository":{"id":85233932,"uuid":"220718190","full_name":"staab/janet-schema","owner":"staab","description":"A schema building and validation library for Janet","archived":false,"fork":false,"pushed_at":"2020-01-24T20:43:05.000Z","size":30,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-12-16T12:31:13.019Z","etag":null,"topics":["janet","schema","validation"],"latest_commit_sha":null,"homepage":null,"language":null,"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/staab.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":"2019-11-09T23:45:49.000Z","updated_at":"2020-01-24T20:43:07.000Z","dependencies_parsed_at":"2024-03-08T09:47:16.676Z","dependency_job_id":null,"html_url":"https://github.com/staab/janet-schema","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/staab/janet-schema","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/staab%2Fjanet-schema","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/staab%2Fjanet-schema/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/staab%2Fjanet-schema/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/staab%2Fjanet-schema/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/staab","download_url":"https://codeload.github.com/staab/janet-schema/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/staab%2Fjanet-schema/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28835150,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-28T02:10:51.810Z","status":"ssl_error","status_checked_at":"2026-01-28T02:10:50.806Z","response_time":57,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["janet","schema","validation"],"created_at":"2024-11-07T19:38:35.643Z","updated_at":"2026-01-28T02:51:46.246Z","avatar_url":"https://github.com/staab.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# janet-schema\n\nA schema library for Janet, inspired by plumatic/schema and jsonschema.\n\n# Status\n\n- [x] Basic type validation\n- [x] Basic constraint validation\n- [ ] Schema (meta) validation\n- [ ] Data coercion based on given schema and coercer\n\n# Usage\n\nImport with:\n\n```\n(use schema)\n```\n\n## Basic\n\nCreate a schema:\n\n```\n(def schema {:stuff [{:a [:int]}]})\n```\n\nCheck your data:\n\n```\n(pp (get-error schema {:stuff [{:a [1 2]} {:a [1 false 3]}]}))\n# =\u003e {:code :type-error\n      :path (:stuff 1 :a 1)\n      :expected :int\n      :actual :boolean\n      :message \"false is not a int\"}\n```\n\n## Advanced\n\nA schema is just a map with a `:t` property that's been registered as a type. `normalize` expands a schema into this format; literals are just a handy shorthand.\n\nIn addition to types, some extra modifiers can be added, depending on what type you're working with.\n\n### Enum\n\nAny schema can be annotated with `:enum`, which should be a tuple of allowed values.\n\n```\n(pp (get-error {:t :any :enum [1 :a \"c\"]} \"d\"))\n# =\u003e {:message \"\\\"d\\\" is not one of [1, :a, \\\"c\\\"]\" ...}\n```\n\n### Maps\n\nMap schemas can be annotated with `:required` properties, and `:closed`, which defaults to false.\n\n```\n(pp (get-error {:t :map :required [:a]} {}))\n# =\u003e {:message \"a is a required property\" ...}\n\n(pp (get-error {:t :map :closed true} {:a 1}))\n# =\u003e {:message \"a is not an allowed property\" ...}\n```\n\n### Constraints\n\nConstraints are additional rules that can be included on a schema which reference parts of the data and impose constraints.\n\nPaths are the key part of constraints; in general they should be integer indexes or associative keys based on the data structure expected. The exception to this is when referencing all values in a dictionary, or a slice of some sequence. The syntax for this is `[:]` with optional indices before and after the colon in the case of indexed data types.\n\n```\n\n(pp\n (get-error\n   {:t :map\n    :constraints [{:t :intersection\n                   :search [:a \"[1:]\"]\n                   :target [:b \"[:]\"]}]}\n   {:a [1 2 3] :b [1 2 3]}))\n# =\u003e {:message \"1 is not contained in the search path\" ...}\n```\n\n## Iteration\n\nIf a single error is desired, `get-error` works great. If more than one error is desired, you can use `check-data`, which directly yields errors to the parent fiber. To control this, call it via a fiber, e.g.,\n\n```\n(loop [error :generate (fiber/new |(check-data schema data)))] ...)\n```\n\n## Extending\n\n### Types\n\nNew types can be created using `define-type`, which takes a type keyword and the following options:\n\n- `:type-is-valid` defines whether data is valid for the given type.\n- `:iter-child-tuples` yields a tuple of `[child-schema child-data child-key]` tuples for recursive validation.\n- `:iter-type-errors` yields any additional errors necessary for validating the type.\n\n### Constraints\n\nNew constraints can be added by registering a method on the `iter-constraint-errors` multimethod, which dispatches on the constraint's `:t` property.\n\nThe registered function should take the desired constraint and the data corresponding to the place in the schema where the constraint was invoked. Constraint functions should yield any errors discovered.\n\n# Disclaimer\n\nThis is pre-alpha software. Breaking changes are likely. Please open an issue if you'd like to use it in a project.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstaab%2Fjanet-schema","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstaab%2Fjanet-schema","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstaab%2Fjanet-schema/lists"}