Giter VIP home page Giter VIP logo

adhere's People

Contributors

davidgwking avatar

Watchers

 avatar

adhere's Issues

definitions and $ref keywords

Implement definitions and $ref utility keywords for sub-schema inlining and recursion.

// should validate [1, 2, [[[[[5], 4]]]], [2]]
{
  // I am a nested array with terminal case positive integer
  type: 'array',
  items: { '$ref': '#recursiveArrayOfPositiveIntegers' },
  definitions: {
    recursiveArrayOfPositiveIntegers: {
      type: ['array', 'number'],
      items: { '$ref': '#recursiveArrayOfPositiveIntegers' },
      minimum: 0,
      exclusiveMinimum: true
    }
  }
}
// should validate [[[[[[5], 4]]]], [2]]
{
  // I am an array of nested arrays with terminal case positive integer 
  type: 'array',
  items: { '$ref': '#recursiveArrayOfPositiveIntegers' },
  definitions: {
    recursiveArrayOfPositiveIntegers: {
      type: 'array',
      items: { '$ref': '#recursiveArrayOfPositiveIntegers' },
      // local definitions always take precedence
      definitions: {
        recursiveArrayOfPositiveIntegers: {
          type: ['array', 'number'],
          minimum: 0,
          exclusiveMinimum: true,
          items: { '$ref': '#recursiveArrayOfPositiveIntegers' },
        }
      }
    }
  }
}
{
  type: 'object',
  anyOf: [{'$ref': '#obj1'}, {'$ref': '#obj2'}],
  definitions: {
    obj1: {type: 'object', minProperties: 5, maxProperties: 9},
    obj2: {type: 'object', minProperties: 10, maxProperties: 20}
  }
}

Optimally, $ref should be able to be used anywhere a sub-schema would typically be acceptable. Interpolated reference schemas should receive a definitions object containing their own definition to enable schema recursion.

object recursion keyword

We will require an object recursion keyword in order to validate schemas since the universal structure is essential recursive.

// could allow mix ins
var s = {
  type: 'object',
  properties: {
    a: {
      type: 'object',
      required: true,
      // recurse on parent schema
      recurse: true
    }
  },
  patternProperties: {
    '^b$': {
      type: 'object',
      // recurse on parent schema (s)
      recurse: true
    }
  }
}

schema validation

Provide a way to validate schemas.

  • each type will need to be defined as a schema (think meta-schema)
  • adequate tests for each schema

streamline missing referenced subschemas

Seek to streamline missing definitions subschemas referred to by a $ref. Currently, we depend on defaulting to an empty schema and the eventual discovery of a lack of type in that empty schema.

Explore returning a schema error in this situation.

refactor away mout dependency

mout has a pretty heavy footprint. Let's do what we can to remove the dependency as it was initially included to get up and running quicker.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.