#!/usr/bin/env node

//
// Notice:
// checkRecursive option は、渡すデータが再帰している場合の話なので、本件には無関係
// https://github.com/geraintluff/tv4#cyclical-javascript-objects
//

var assert = require('assert');
var tv4 = require('tv4');


var schema, validated;

schema = {
  definitions: {
    foo: {
      type: 'object',
      properties: {
        x: {
          $ref: '#/definitions/foo'
        },
        y: {
          type: 'string'
        }
      },
      required: ['y']
    }
  },
  type: 'object',
  properties: {
    by_ref: {
      $ref: '#/definitions/foo'
    }
  }
};

validated = tv4.validateMultiple({
  by_ref: {
    x: {
      y: 'a'
    },
    y: 'a'
  }
}, schema);
assert.strictEqual(validated.errors.length, 0);

validated = tv4.validateMultiple({
  by_ref: {
    x: {
      x: {
        x: {
          y: 'a'
        },
        y: 'a'
      },
      y: 'a'
    },
    y: 'a'
  }
}, schema);
assert.strictEqual(validated.errors.length, 0);

validated = tv4.validateMultiple({
  by_ref: {
    x: {
      x: {
        x: {
        },
        y: 'a'
      },
      y: 'a'
    },
    y: 'a'
  }
}, schema);
assert.strictEqual(validated.errors.length, 1);

@@ -1152,8 +1152,1208 @@
 th, 1);%0A
+%0A%0A//%0A// %5B%7B children: %5B%5D %7D%5D %E3%81%AE%E5%86%8D%E5%B8%B0%0A//%0A%0Avar schema2 = %7B%0A  children: %7B%0A    type: 'array',%0A    items: %7B%0A      type: 'object',%0A      required: %5B%0A        'name',%0A        'children',%0A      %5D,%0A      properties: %7B%0A        name: %7B%0A          type: 'string',%0A        %7D,%0A        children: %7B%0A          $ref: '#/children'%0A        %7D,%0A      %7D,%0A    %7D,%0A  %7D,%0A  $ref: '#/children'%0A%7D;%0A%0Avar validated2;%0A%0Avalidated2 = tv4.validateMultiple(%5B%0A  %7B%0A    name: 'oya',%0A    children: %5B%5D,%0A  %7D,%0A%5D, schema2);%0Aassert.strictEqual(validated2.errors.length, 0);%0A%0Avalidated2 = tv4.validateMultiple(%5B%0A  %7B%0A    name: 'oya',%0A    children: %5B%0A      %7B%0A        name: 'ko1',%0A        children: %5B%0A          %7B%0A            name: 'mago',%0A            children: %5B%5D,%0A          %7D%0A        %5D,%0A      %7D,%0A      %7B%0A        name: 'ko2',%0A        children: %5B%5D,%0A      %7D,%0A    %5D,%0A  %7D,%0A%5D, schema2);%0Aassert.strictEqual(validated2.errors.length, 0);%0A%0Avalidated2 = tv4.validateMultiple(%5B%0A  %7B%0A    name: 'oya',%0A    children: %5B%0A      %7B%0A        name: 'ko1',%0A        children: %5B%0A          %7B%0A            children: %5B%5D,%0A          %7D%0A        %5D,%0A      %7D,%0A      %7B%0A        name: 'ko2',%0A        children: %5B%5D,%0A      %7D,%0A    %5D,%0A  %7D,%0A%5D, schema2);%0Aassert.strictEqual(validated2.errors.length, 1);%0A

Add a sample of the tv4