hoodwink.d enhanced
RSS
2.0
XHTML
1.0

RedHanded

Kwalify is YAML Schemas #

by why in inspect

Wow, look what showed up today. Kwalify.

If you have a YAML document that looks like this:

 name:   foo
 email:  foo@mail.com
 age:    20
 birth:  1985-01-01

Add a Kwalify schema file:

 type: map
 mapping:
   name: {type: string, required: yes}
   email: {type: string, pattern: /@/}
   age: {type: integer}
   birth: {type: date}

To validate:

 kwalify -f schema.yaml example.yaml

KWOOL!! In hasty eagerness, I whipped up a schema for an example feed. Well done, Makoto Kuwata! To boot, the validator is perfectly scriptable. (Seen on del.icio.us/tag/yaml.)

said on 01 Aug 2005 at 10:13

And it’s pure YAML , even! I’m going to start on the YSL and YPath specs right away!

We’ll need to add namespaces first…

said on 01 Aug 2005 at 10:28

My goodness!

How very expected … and yet I didn’t see it coming.

Everybody needs a schema.

said on 01 Aug 2005 at 12:02

Nice! The schema has a fairly nice look-alike design, which is exactly what I’ve hoped for in a YAML schema (instead the usual less asthetic decription-based designs). I couldn’t quite figure it out myself when I tried, and am very happy to see someone did! Good job!

said on 01 Aug 2005 at 22:29

It might be interesting to see if you can use (whatever little of) ’s type system to validate the markup. That way your schema IS your program.

said on 02 Aug 2005 at 07:37

Sam, can you explain more?

said on 03 Aug 2005 at 01:20

Well yaml appears to already map data to different types in a language. Maybe some runtime typechecking based on how the data is used in the program can be used to determine the validity of the markup.

said on 18 Jan 2006 at 02:13

Whoa, I just realized… the way kwalify works, it can basically be used as a form of type-checking for arbitrary data structures in ruby. Since you have to load both the YAML and the schema into native structure anyway, you don’t actually need YAML anywhere in the process.

Comments are closed for this entry.