{"id":25668059,"url":"https://github.com/milihhard/yaml-validator-typescript","last_synced_at":"2026-05-15T17:36:47.144Z","repository":{"id":42859675,"uuid":"259834662","full_name":"Milihhard/yaml-validator-typescript","owner":"Milihhard","description":"Yaml validator for Node.js to test your yaml with a defined model","archived":false,"fork":false,"pushed_at":"2023-01-06T04:35:51.000Z","size":486,"stargazers_count":0,"open_issues_count":10,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-08T22:03:40.261Z","etag":null,"topics":["validator","yaml","yaml-validator-typescript"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/yaml-validator-typescript","language":"TypeScript","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/Milihhard.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":"2020-04-29T05:40:23.000Z","updated_at":"2020-05-01T09:17:46.000Z","dependencies_parsed_at":"2023-02-05T08:16:03.859Z","dependency_job_id":null,"html_url":"https://github.com/Milihhard/yaml-validator-typescript","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Milihhard%2Fyaml-validator-typescript","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Milihhard%2Fyaml-validator-typescript/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Milihhard%2Fyaml-validator-typescript/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Milihhard%2Fyaml-validator-typescript/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Milihhard","download_url":"https://codeload.github.com/Milihhard/yaml-validator-typescript/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240460656,"owners_count":19804941,"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":["validator","yaml","yaml-validator-typescript"],"created_at":"2025-02-24T10:28:19.052Z","updated_at":"2026-05-15T17:36:47.085Z","avatar_url":"https://github.com/Milihhard.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# yaml-validator-typescript\n\n[![Coverage Status](https://coveralls.io/repos/github/Milihhard/yaml-validator-typescript/badge.svg?branch=master)](https://coveralls.io/github/Milihhard/yaml-validator-typescript?branch=master) ![Testing app](https://github.com/Milihhard/yaml-validator-typescript/workflows/Testing%20app/badge.svg) ![Building](https://github.com/Milihhard/yaml-validator-typescript/workflows/Building/badge.svg) ![Publish to npm](https://github.com/Milihhard/yaml-validator-typescript/workflows/Publish%20to%20npm/badge.svg)\n\nyaml-validator-typescript is a way to validate your Yaml file by using a defined model\n\n## Installation\n\n```bash\n$npm install yaml-validator-typescript\n```\n\nor\n\n```bash\n$yarn add yaml-validator-typescript\n```\n\n## Usage\n\n## Define your modele\n\nYou can set you model as you want. You just need to have properties initialized\n\nIf you don't want some property to be tested, you can implement `Yaml`\n\n```javascript\nclass TestOnlyKeys implements Yaml {\n    keysToTest: (keyof TestOnlyKeys)[] = ['key1', 'key2'];\n    key1: string = '';\n    key2: number = 0;\n    keyNotToTest: boolean = false;\n}\n```\n\n\u003e Here only `key1` and `key2` are tested\n\u003e You can also set some properties optionals:\n\n```javascript\nclass Optional implements Yaml {\n    keysToTest: string[] = ['valueToHave', 'valueOptional', 'arrayOptional'];\n    optionals: Set\u003cstring\u003e = new Set(['valueOptional', 'arrayOptional']);\n    valueToHave: string = '';\n    valueOptional: string = '';\n    arrayOptional: {valueYouNeed1: string, valueYouNeed2: boolean}[] = [\n        {valueYouNeed1: '', valueYouNeed2: true},\n    ];\n}\n```\n\n\u003e Here `valueOptional` and `arrayOptional` are optionals\n\u003e But if `arrayOptional` is defined, he has to be right\n\n### As a command\n\nSet a config file at the root of the project:\n\n```javascript\nimport MyClass from './somewhere';\nmodule.exports = {\n    structure: new MyClass(),\n    files: ['file1.yaml', 'file2.yaml'],\n};\n```\n\nThen run the command\n\n```json\n{\n    \"scripts\": {\n        \"valid-yaml\": \"validate-yaml\"\n    }\n}\n```\n\n\u003e If you have not set the files, you can put them in the command\n\n```json\n{\n    \"scripts\": {\n        \"valid-yaml\": \"validate-yaml file1.yaml file2.yaml\"\n    }\n}\n```\n\n### In your code\n\n```typescript\nimport MyClass from './somewhere';\nconst validator = new Validator(new MyClass());\nvalidator.validate('path_of_my_file.yaml').then((errors) =\u003e {\n    if (errors.length \u003e 0) {\n        console.log('I have some issues I need to fix 🙀');\n        errors.forEach((error) =\u003e {\n            console.log(`- ${result}`);\n        });\n    } else {\n        console.log('No Error in this code 💪');\n    }\n});\n```\n\nYou can validate multiple file at the same time with the same validator\n\n```typescript\nimport MyClass from './somewhere';\nconst validator = new Validator(new MyClass());\nvalidator\n    .validateMany('path_of_my_file.yaml', 'another_path_of_my_file.yaml')\n    .then((results) =\u003e {\n        files.forEach((file) =\u003e {\n            console.log(`${file.name}:`);\n            if (file.results.length \u003e 0) {\n                console.log('I have some issues I need to fix 🙀');\n                file.results.forEach((error) =\u003e {\n                    console.log(`- ${result}`);\n                });\n            } else {\n                console.log('No Error in this code 💪');\n            }\n        });\n    });\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmilihhard%2Fyaml-validator-typescript","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmilihhard%2Fyaml-validator-typescript","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmilihhard%2Fyaml-validator-typescript/lists"}