Yaml schema Validation powershell

北战南征 提交于 2021-02-17 00:54:07

问题


I'm working with powershell-yaml to parse my YAML into a PowerShell object.

currently, I have a problem validating my YAML schema. I've used this package yaml-schema-validator for my javascript project and I couldn't find any familiar function\moudle to help me solve this problem with Powershell.

Is There a schema validation language for YAML in Powershell?


回答1:


Simply put, no, I don't believe there are any Powershell native options for doc validation against a YAML schema.

Since YAML is a super-set of JSON, one could (depending on the YAML being validated), use a schema expressed in JSON and validated w/Test-JSON.

There are two active YAML modules I'm aware of: (1) PSYaml and (2) powershell-yaml. The second being what you use today. I don't believe either of them validate YAML docs against a schema.

I believe there are schema validation modules/projects in the following:

  • Ruby
  • Python
  • PHP
  • JavaScript

You can see the list in Schema Validation for YAML.

You could always do you validation in another language, and wrap that call in Powershell. You just have to handle the integration yourself.



来源:https://stackoverflow.com/questions/57253836/yaml-schema-validation-powershell

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!