GithubHelp home page GithubHelp logo

Command line interface about jsv HOT 4 OPEN

garycourt avatar garycourt commented on July 21, 2024
Command line interface

from jsv.

Comments (4)

garycourt avatar garycourt commented on July 21, 2024

I guess I could. Or you could. :)

from jsv.

hickford avatar hickford commented on July 21, 2024

Hi I tried.

JSV = require('jsv').JSV
fs = require('fs')

raw_object = fs.readFileSync(process.argv[2])
object = JSON.parse(raw_object)

raw_schema = fs.readFileSync(process.argv[3])
schema = JSON.parse(raw_schema)

env = JSV.createEnvironment()
report = env.validate(object, schema)

console.log(report.errors)

JSON Schemas can themselves be described using JSON Schemas. A self-describing JSON Schema for the core JSON Schema can be found at http://json-schema.org/schema for the latest version or http://json-schema.org/draft-03/schema for the draft-03 version.

But I can't get the self-describing schema to validate against itself. I get errors:

$ coffee validate.coffee schema schema
[ { uri: 'http://json-schema.org/schema#/properties/properties/additionalProperties',
    schemaUri: 'http://json-schema.org/draft-03/hyper-schema#/properties/additionalProperties',
    attribute: 'type',
    message: 'Instance is not a required type',
    details: [ 'http://json-schema.org/draft-03/hyper-schema#', 'boolean' ] },
  { uri: 'http://json-schema.org/schema#/properties/items/items',
    schemaUri: 'http://json-schema.org/draft-03/hyper-schema#/properties/items',
    attribute: 'type',
    message: 'Instance is not a required type',
    details: [ 'http://json-schema.org/draft-03/hyper-schema#', 'array' ] },
  { uri: 'http://json-schema.org/schema#/properties/extends/items',
    schemaUri: 'http://json-schema.org/draft-03/hyper-schema#/properties/items',
    attribute: 'type',
    message: 'Instance is not a required type',
    details: [ 'http://json-schema.org/draft-03/hyper-schema#', 'array' ] } ]

from jsv.

garycourt avatar garycourt commented on July 21, 2024

Are you overriding the builtin schema/hyper schema by loading a new one in? It'll probably fail in that case.

from jsv.

hickford avatar hickford commented on July 21, 2024

https://github.com/zaach/jsonlint , a command-line tool, now uses JSV for this

from jsv.

Related Issues (20)

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.