Kwalify is YAML Schemas #
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.)
anonymous coward
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…
MenTaLguY
My goodness!
How very expected … and yet I didn’t see it coming.
Everybody needs a schema.
trans
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!
Sam
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.
trans
Sam, can you explain more?
Sam
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.
crzwdjk
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.