#StackBounty: #json #go #yaml Validate yaml schema with Golang for specifed schema structure (semantic)

Bounty: 100

We have tool which need to read yaml file with specific structure.
When we got the yaml file we need to know if

  1. Check if the yaml file is valid according to some guideline – semantic check
  2. Where is the syntax error if any

For example this is example of the validation that we need to address

   _version:  {required: true}
   id: {required: true, pattern: '/^[A-Za_-.]+$/'}   
   release-version: {required: true}
   type:   

   builds:
     type:seq
     sequence:
       -type:map
     mapping:
        name:{required: true, unique: true, pattern: '/^[A-Za-z0-3_-.]+$/'}
        params: 
          type: map
          mapping: { =: {type: any} } 
  1. Mapping is a key value object
  2. seq can have multiple builds
  3. type any is and key value

We use this open source to parse the yaml
https://github.com/go-yaml/yaml

There is Idea to use json like following to do it by converting the file
to json and validate it, any example in my context will be very helpful
https://github.com/xeipuuv/gojsonschema


Get this bounty!!!

Leave a Reply