# Kwalify 0.7.0 - parser, schema validator, and data binding for YAML and JSON

**URL:** <https://www.ruby-forum.com/t/kwalify-0-7-0-parser-schema-validator-and-data-binding-for-yaml-and-json/127272>\
**Category:** Ruby\
**Created:** [January 27, 2008, 4:45pm UTC](https://www.ruby-forum.com/t/kwalify-0-7-0-parser-schema-validator-and-data-binding-for-yaml-and-json/127272 "2008-01-27T16:45:58Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![makoto\_kuwata](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/a4c791/32.png) [@makoto\_kuwata](https://www.ruby-forum.com/u/makoto_kuwata)\
**Post date:** [January 27, 2008, 4:45pm UTC](https://www.ruby-forum.com/t/kwalify-0-7-0-parser-schema-validator-and-data-binding-for-yaml-and-json/127272/1 "2008-01-27T16:45:58Z")

</div>

Hi,

I have released Kwalify 0.7.0.  
[http://www.kuwata-lab.com/kwalify/](http://www.kuwata-lab.com/kwalify/)

Kwalify is an integrated tool for YAML and JSON.  
Kwalify contains parser, schema validator, and data binding tool.

This release has many enhancements and changes.  
See  
[http://kuwata-lab.com/kwalify/ruby/CHANGES.txt](http://kuwata-lab.com/kwalify/ruby/CHANGES.txt)  
for details.

From this release, Kwalify supports data binding.  
If you specify class name in schema definition, Kwalify parses YAML/  
JSON  
and create instance object of that class instead of Hash object.  
Data binding makes handling YAML easier.

Example:

- 
## schema file (config.schema.yaml)

## type: map class: Config mapping: “host”: { type: str, required: true } “port”: { type: int } “user”: { type: str, required: true } “pass”: { type: str, required: true }
- 
## configuration file (config.yaml)

## host: localhost user: user1 pass: password1
- 
## ruby program (ex1.rb)

## class definition

require ‘kwalify/util/hashlike’  
class Config  
include Kwalify::Util::HashLike # defines [], []=, …  
attr\_accessor :host, :posrt, :user, :pass  
def initialize  
@port = 80  
end  
end

## create validator object

require ‘kwalify’  
schema = Kwalify::Yaml.load\_file(‘config.schema.yaml’)  
validator = Kwalify::Validator.new(schema)

## parse configuration file with data binding

## parser = Kwalify::Yaml::Parser.new(validator) parser.data\_binding = true # enable data binding config = parser.parse\_file(‘config.yaml’) p config #=\> #\<Config:0x542590 @user=“user1”, @port=80, # @pass=“password1”, @host=“localhost”\>

See User’s Guide for details.  
[http://www.kuwata-lab.com/kwalify/ruby/users-guide.html](http://www.kuwata-lab.com/kwalify/ruby/users-guide.html)
