Schema to validate null entries

535 Views Asked by At

I am new to yml.

My yml data file may or may not contain names under "reference:" tag in it. Basically, it could just be empty, So for successful validation I made it 'required: no'

type: map
mapping:
  file:
    type: seq
    sequence:
      - type: map
        mapping:
          project:
            type: str
            required: yes
          sub:
            type: str
            required: yes
          source:
            type: str
            required: yes
          reference:
            type: seq
            required: no
            sequence:
              - type: map
                mapping:
                  name:
                    type: str
                    required: no
                    unique: yes

When I try to validate yml using Kwalify.pm , it fails with issue:-

 warning: Use of uninitialized value $data in concatenation (.) or string at /home/nv/utils/MFT/perl/lib/Kwalify-1.22/lib/Kwalify.pm

Need yml experts help in this. Thanks!

1

There are 1 best solutions below

4
flyx On BEST ANSWER

sequence:, standing separately without following more-indented content, produces a key-value pair with sequence as key and an empty scalar as value. An empty scalar will be processed either into an empty string or null, neither of which is a sequence as required by your schema.

To have an empty mapping, write sequence: [].