April 09, 2023

Hi All,

I am trying to use D-YAML for one of my project, and just tired the example for this link https://dlang-community.github.io/D-YAML/tutorials/getting_started.html, the example is working fine, so i would like to know who to i validate the node, eg

Example Code

import std.stdio;
import std.algorithm;
import dyaml;


alias isReserverd = among!("name", "type");

int main(string[] args)
{
	
   string path = "input.yml";
    try
    {
       auto loader = Loader.fromFile(path);
       auto root = loader.load();
       if(root[*].isReserverd)     // This is condition
        {
            writeln(root[*]);
            return 0;
        }
    }
    catch(YAMLException e)
    {
        writeln(e.msg);
    }

    writeln("FAILURE");
    return 1;
}

input.yml

name: Test
type: A
records: 10

Required output

Test
A

From,
Vino.B