问题
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