{"id":22981016,"url":"https://github.com/rubyworks/yes","last_synced_at":"2025-08-13T17:33:41.669Z","repository":{"id":56899089,"uuid":"1958474","full_name":"rubyworks/yes","owner":"rubyworks","description":"YAML Easy Schemas","archived":false,"fork":false,"pushed_at":"2014-04-23T16:24:59.000Z","size":624,"stargazers_count":2,"open_issues_count":1,"forks_count":3,"subscribers_count":5,"default_branch":"master","last_synced_at":"2024-11-19T08:29:05.902Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://rubyworks.github.com/yes","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rubyworks.png","metadata":{"files":{"readme":"README.md","changelog":"HISTORY.md","contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2011-06-27T04:18:56.000Z","updated_at":"2024-01-11T18:24:00.000Z","dependencies_parsed_at":"2022-08-21T01:50:24.228Z","dependency_job_id":null,"html_url":"https://github.com/rubyworks/yes","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/rubyworks%2Fyes","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rubyworks%2Fyes/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rubyworks%2Fyes/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rubyworks%2Fyes/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rubyworks","download_url":"https://codeload.github.com/rubyworks/yes/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":229773540,"owners_count":18122031,"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":[],"created_at":"2024-12-15T01:46:44.876Z","updated_at":"2024-12-15T01:46:45.551Z","avatar_url":"https://github.com/rubyworks.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"YES - YAML Easy Schema\n======================\n\nYES is a schema system for YAML that is intuitive and powerful.\nYES schemas are also YAML documents, so it \"eats its own dog food\",\nas they say.\n\n## HOW IT WORKS\n\nThe design of YES is rather simple. A YES schema is composed of YPath\nselectors mapped to document constraints. A YES document can be either\na mapping or a sequence of such constraints. YPath is a syntax for\nselecting *nodes* from a YAML document.\n\nWhen validating a YAML document against a YES schema a \"lint\" program\nsimply collects all matching nodes with their applicable constraints into\na collection of *unit-validations*. Then this collection is filtered of \nall *passing* validations. All that is left are the failures. If the \nfiltered list is empty the document is completely valid. If not empty,\nthe lint program can provide a detailed *editorial* list of the failures.\n\nIn general, contraints limit the possible nodes in a document. Some\ncontraints are *specifiers* which instruct parsers how to interpret a\ndocument based on it's structure (as opposed to document tags).\n\n\n## Note About miniKanren\n\nAlthough YES was conceived of and partially implemented before we\never heard of [miniKanren](http://minikanren.org/), it later become\napparent that YES is essentially a DSL variant on miniKanren for the\nspecific purpose of creating schema for YAML documents. This presents\na rather fruitful possibility that core logic of miniKanren implementations,\nalready in the wild, could be used as a basis for creating YES implementations.\n\n\n## Examples\n\nLets take an example schema:\n\n    people/*/name:\n      implicit: !name\n      regexp: '[^/n]'\n\nThis simple schema selects all nodes under a `people` sequence of\nmappings with a `name` key, the value of which cannot contain newlines\ndue to the `regex` constraint, and should be parsed with implcit tag\nof `!name`, as specified by the `implicit` constraint.\n\nThe following document would satisfy the schema:\n\n    people:\n      - name: Charlie Adams\n      - name: Julie Ann Rose\n\nBut this would not:\n\n    people:\n      - name: |\n          Charlie\n          Adams\n\nSometimes multiple constraints of the same type need to be applied to \na set of nodes. This can be done by expressing the same YPath with \ndifferent constraints, for example:\n\n    - people/*/name:\n        regexp: '[^/t]'\n    - people/*/name:\n        regexp: '[^/n]'\n\nBut to make the intent more succinct a sequence of constraints instead of\na mapping can be given.\n\n    people/*/name:\n      - regexp: '[^/t]'\n      - regexp: '[^/n]'\n\nThis construct implies *logical-and* relation. This can be explicitly given\nwith a `!!and` tag.\n\n    people/*/name: !!and\n      - regexp: '[^/t]'\n      - regexp: '[^/n]'\n\nWhich as you may have guessed means `!!or` can be used to explicity create a\n*logical-or* constraint relation:\n\n    people/*/name: !!or\n      - regexp: '[^/t]'\n      - regexp: '[^/n]'\n\nIn this way complex logical relationships of constraints can be created.\n\n    people/*/login: !!or\n      - !!and\n        - implicit: !id\n        - regexp: '^\\d+$'\n      - !!and\n        - implicit: !name\n        - regexp: '^\\w+$'\n\n(Of course these examples can be better handled via more sophisticated regular\nexpressions, but the intent is only to show that logical operations are possible.)\n\n(NOT IMPLEMENTED YET) By preceding a subentry with slash (`/`) YES will interpret\nthe entry as a continutation of the parent YPATH rather than node criteria.\n\n    - people/*:\n        /name:\n          regexp: '[^/t]'\n\nIn this way schemas can often be more reflective of the the actual structure of the\ndocument they formailze.\n\nIn the above example we have only shown examples of `regexp` and `implicit` contraints,\nbut there are many other types including: *count*, *length*, *required*, *tag*,\n*value*, etc. See the [DEMO.md](DEMO.md) file for details.\n\n\n## COMMAND LINE\n\nTo use on the command line *lint* tool. Say we have a `schema.yes` file:\n\n    --- !!yes\n    name:\n      type: str\n      regexp: '[^\\n]'\n      required: true\n    age:\n      type: int\n    birth:\n      type: date\n\nTry it on `sample.yaml`.\n\n    ---\n    name: Thomas T. Thomas\n    age: 42\n    birth: 1976-07-04\n\nUsing the executable.\n\n    $ yes-lint schema.yes sample.yaml\n\nIn code that is:\n\n    require 'yes'\n\n    lint = YES::Lint.new(File.new('schema.yes'))\n\n    lint.validate(File.new('sample.yaml'))\n\n\n## CONTRIBUTE\n\nCome on folks! Let's get YAML up to snuff. A good Schema could really\nhelp YAML go the distance and penetrate some of those \"Enterprisey\" worlds.\n\n* Please read, write and comment on issues[https://github.com/rubyworks/yes/issues].\n* Please critique the code.\n* Please fork and submit patches in topic branches.\n\nAnd please contribute to {Rubyworks Ruby Development Fund}[http://rubyworks.github.org]\nso us poor Ruby OSS developers can eat :)\n\n\n## COPYRIGHT\n\nCopyright (c) 2011 Rubyworks \n\n[BSD-2 License](LICENSE.txt)\n\nSee LICENSE.txt for details.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frubyworks%2Fyes","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frubyworks%2Fyes","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frubyworks%2Fyes/lists"}