{"id":26119481,"url":"https://github.com/mmontone/schemata","last_synced_at":"2025-04-13T11:11:54.088Z","repository":{"id":138624664,"uuid":"264711320","full_name":"mmontone/schemata","owner":"mmontone","description":"Schema serialization, validation and parsing for Common Lisp.","archived":false,"fork":false,"pushed_at":"2024-05-03T11:53:50.000Z","size":1412,"stargazers_count":11,"open_issues_count":0,"forks_count":3,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-27T02:21:46.353Z","etag":null,"topics":["common-lisp","json-schema","lisp","schema","serialization","validation"],"latest_commit_sha":null,"homepage":"https://mmontone.github.io/schemata/","language":"Common Lisp","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/mmontone.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-05-17T16:37:01.000Z","updated_at":"2025-02-17T07:27:35.000Z","dependencies_parsed_at":null,"dependency_job_id":"2b365f8e-8a20-4252-ae0a-b06bf98c20a1","html_url":"https://github.com/mmontone/schemata","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mmontone%2Fschemata","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mmontone%2Fschemata/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mmontone%2Fschemata/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mmontone%2Fschemata/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mmontone","download_url":"https://codeload.github.com/mmontone/schemata/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248703199,"owners_count":21148118,"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":["common-lisp","json-schema","lisp","schema","serialization","validation"],"created_at":"2025-03-10T12:55:11.203Z","updated_at":"2025-04-13T11:11:54.066Z","avatar_url":"https://github.com/mmontone.png","language":"Common Lisp","funding_links":[],"categories":[],"sub_categories":[],"readme":"# SCHEMATA\n\nGeneric purpose schema library for serialization and validation of data.\n\nThis library is used by CL-REST-SERVER for API serialization and validation.\n\nIt features:\n- Validation using schemas.\n- Serialization and unserialization using schemas.\n- Generation of (random) data from schemas. (incomplete implementation atm)\n- JSON-Schema parsing (incomplete implementation atm)\n- Itegration with Common Lisp type system.\n- A schema class metaclass.\n\n## Example\n\n```lisp\n(schemata:defschema customer\n    (object \"customer\"\n             ((id string :external-name \"id\" :accessor\n                  customer-id :documentation \"customer id\")\n              (number string :external-name \"number\" :required nil\n                              :accessor customer-nr :documentation\n                      \"customer number\")\n              (name string :external-name \"name\" :accessor\n                    customer-name :documentation \"customer name\")\n              (address-1 string :external-name \"address1\"\n                                 :required nil :documentation\n                         \"customer first address\")\n              (address-2 string :external-name \"address2\"\n                                 :required nil :documentation\n                         \"customer second address\")\n              (postal-code string :external-name \"postalcode\"\n                                   :required nil :documentation\n                           \"postal code\")\n              (postal-area string :external-name \"postalarea\"\n                                   :required nil :documentation\n                           \"postal area\")\n              (country string :external-name \"country\" :required nil \n                       :documentation \"country code\")\n              (phone string :external-name \"phone\" :required nil\n                             :documentation \"phone\")\n              (fax string :external-name \"fax\" :required nil\n                           :documentation \"fax\")\n              (email string :external-name \"email\" :required nil\n                             :documentation \"email\"))\n             (:documentation \"customer data fetched\")))\n```\n\n[Read the full documentation](https://mmontone.github.io/schemata/ \"Full documentation\")\n\n## Schema types\n\n### Type schemas\n\nSchemas can be built from Common Lisp types:\n\n```lisp\nSCHEMATA\u003e (defparameter *s* (schema string))\n*S*\nSCHEMATA\u003e *s*\n#\u003cTYPE-SCHEMA STRING {1006FBBD13}\u003e\nSCHEMATA\u003e (validate-with-schema *s* \"22\")\nNIL\nSCHEMATA\u003e (validate-with-schema *s* 22 :error-p nil)\n#\u003cVALIDATION-ERROR \"~s is not of type: ~a\" {100152EB13}\u003e\n```\n\n### Object schema\n\nObject schemas are built using the syntax: `(object name attributes options)`.\nAttributes are specified as: `(attribute-name attribute-type \u0026rest options)`.\n\nThe `attribute-type` is parsed as a schema.\n\nPossible attribute options are: `required`, `required-message`, `default`, `accessor`, `writer`, `reader`, `parser`, `validator`, `add-validator`, `formatter`, `external-name`, `serializer`, `unserializer`, `slot`.\n\nExample:\n\n```lisp\nSCHEMATA\u003e (schema (object person\n                          ((name string)\n                           (age integer :required nil))))\n#\u003cOBJECT-SCHEMA {1001843543}\u003e\n```\n\n### List schema\n\nHomogeneous list of schemas are specified via `list-of`.\n\nExample:\n\n```lisp\nSCHEMATA\u003e (defparameter *s* (schema (list-of integer)))\n*S*\nSCHEMATA\u003e (validate-with-schema *s* '(1 2 \"foo\"))\n; Evaluation aborted on #\u003cSCHEMATA:VALIDATION-ERROR \"~s is not of type: ~a\" {1006ECA323}\u003e.\nSCHEMATA\u003e (validate-with-schema *s* '(1 2 3))\nNIL\n```\n### Schema references\n\nDefined schemas can be referenced via either `(schema schema-name)` or `(ref schema-name)` (they are identical).\n\nExample:\n\n```lisp\nSCHEMATA\u003e (defschema person\n            (object person\n                    ((name string))))\n#\u003cOBJECT-SCHEMA {1006F8A813}\u003e\nSCHEMATA\u003e (defparameter *list-of-person* (schema (list-of (ref person))))\n*LIST-OF-PERSON*\nSCHEMATA\u003e *list-of-person*\n#\u003cLIST-SCHEMA {1006F8C2A3}\u003e\nSCHEMATA\u003e (parse-with-schema *list-of-person* '(((\"name\" . \"Mariano\")) ((\"name\" . \"Peter\"))))\n(((NAME . \"Mariano\")) ((NAME . \"Peter\")))\nSCHEMATA\u003e (validate-with-schema *list-of-person* '(((\"name\" . 22)) ((\"name\" . \"Peter\"))))\n; processing (DEFMETHOD SCHEMA-VALIDATE ...); Evaluation aborted on #\u003cSB-PCL::NO-APPLICABLE-METHOD-ERROR {1008018513}\u003e.\nSCHEMATA\u003e (validate-with-schema *list-of-person* '(((\"name\" . 22)) ((\"name\" . \"Peter\"))))\n; Evaluation aborted on #\u003cSCHEMATA:VALIDATION-ERROR \"~s is not of type: ~a\" {10082EB883}\u003e.\nSCHEMATA\u003e (validate-with-schema *list-of-person* '(((\"name\" . \"Mariano\")) ((\"name\" . \"Peter\"))))\nNIL\nSCHEMATA\u003e (validate-with-schema *list-of-person* '(((\"names\" . \"Mariano\")) ((\"name\" . \"Peter\"))))\n; Evaluation aborted on #\u003cSCHEMATA:VALIDATION-ERROR \"Attributes not part of schema: ~a\" {1008CD3DD3}\u003e.\n```\n\n## SATISFIES-SCHEMA type\n\nSchemata integrates with the Lisp type system via the SATISFIES-SCHEMA type.\nSchemas can be thought as types over data.\nDefined schemas can be checked using TYPEP and CHECK-TYPE with the type `(satisfies-schema schema-name)`.\n\nExample:\n\n```lisp\nSCHEMATA\u003e (defschema string-schema string)\n#\u003cTYPE-SCHEMA STRING {10019DA8B3}\u003e\nSCHEMATA\u003e (typep \"foo\" '(satisfies-schema string-schema))\nT\nSCHEMATA\u003e (typep 22 '(satisfies-schema string-schema))\nNIL\nSCHEMATA\u003e (let ((x \"foo\"))\n            (check-type x (satisfies-schema string-schema))\n            x)\n\"foo\"\n```\n\n## SCHEMA-CLASS metaclass\n\nSCHEMA-CLASS classes get an schema attached.\n\nExample:\n\n```lisp\nSCHEMATA\u003e (def-schema-class person ()\n            ((name :type string :initarg :name)\n             (age :type integer :required nil :initarg :age)))\n#\u003cSCHEMA-CLASS SCHEMATA::PERSON\u003e\n\nSCHEMATA\u003e (validate-with-schema (find-class 'person) '((\"name\" . \"Mariano\") (\"age\" . 22)))\nNIL\n\nSCHEMATA\u003e (validate-with-schema (find-class 'person) '((\"name\" . \"Mariano\") (\"age\" . 'asdf)) :error-p nil)\n#\u003cVALIDATION-ERROR 'ASDF is not of type: INTEGER {100109F833}\u003e\n\nSCHEMATA\u003e (generic-serializer:with-serializer :json\n            (generic-serializer:serialize (make-instance 'person :name \"Mariano\" :age 44)))\n{\"name\":\"Mariano\",\"age\":44}\n```\n\n## More schema types\n\n[Read more](https://mmontone.github.io/schemata/#Schema-types) about other schema types, like association-lists, property-lists, hash-tables, etc.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmmontone%2Fschemata","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmmontone%2Fschemata","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmmontone%2Fschemata/lists"}