Constellation/ruby-jsonchema — pull request #5 by coneybeare (2012-02-18 18:15:23+00:00)
Title: Make life easier with kind_of?

Changing the instance_of? to kind_of? calls allows subclasses to be validated as well. This immediately helps rails3 apps as you can validate the params hash which is a ActiveSupport::HashWithIndifferentAccess, a subclass of Hash that allows strings or symbols to be used. This makes validating easy with something like this:

````ruby
before_filter :validate_json, :only => :create
...
def validate_json
begin
schema = SCHEMAS[@api_version]
JSON::Schema.validate(params, schema)
rescue Exception => e
render :json => {:errors => [e.to_s]}
end
end
````