Giter VIP home page Giter VIP logo

Comments (7)

geotom avatar geotom commented on May 23, 2024 3

Same here: Had to add "url" to my packages, and then in the code where i use it I had to import as well before calling the validation (import * as url from "url"). Otherwise the validation throws an error that urilib.resolve is not a method

from jsonschema.

AlexPernot avatar AlexPernot commented on May 23, 2024 2

Same, it seems the lib was designed with only Node in mind. If you are in the browser, you will need to install "url" from npm to have the url.resolve function. I don't know why it broke recently, I guess "url" was installed by another dependency.

from jsonschema.

gugurete avatar gugurete commented on May 23, 2024 1

Yes, tdegrunt/jsonschema has an implicit dependency on the "url" library.
It would be nice to make this explicit or even better ditch it altogether to have a nice, lean, no external dependencies jsonschema validator

from jsonschema.

tdegrunt avatar tdegrunt commented on May 23, 2024 1

The above PR should address this issue.

from jsonschema.

awwright avatar awwright commented on May 23, 2024

The "url" package should be builtin. It is not supposed to refer to a third-party package. Can you tell me a little more about your environment?

from jsonschema.

gugurete avatar gugurete commented on May 23, 2024

Environment: Browser (vuejs, vite).

The uri library is only present in nodejs, the browser does not have it, the jsonschema package.json should explicitely specify this library
var urilib = require('url');

validator.js:118 Uncaught (in promise) TypeError: urilib.resolve is not a function
at Validator2.validate (validator.js:118:21)
at module.exports.validate (index.js:14:12)
at Proxy.validate (edit.vue:81:39)

...

var urilib = require('url');
/**

  • Validates instance against the provided schema
  • @param instance
  • @param schema
  • @param [options]
  • @param [ctx]
  • @return {Array}
    */
    Validator.prototype.validate = function validate (instance, schema, options, ctx) {
    if((typeof schema !== 'boolean' && typeof schema !== 'object') || schema === null){
    throw new SchemaError('Expected schema to be an object or boolean');
    }
    if (!options) {
    options = {};
    }
    // This section indexes subschemas in the provided schema, so they don't need to be added with Validator#addSchema
    // This will work so long as the function at uri.resolve() will resolve a relative URI to a relative URI
    var id = schema.$id || schema.id;
    var base = urilib.resolve(options.base||anonymousBase, id||'');

from jsonschema.

smeng9 avatar smeng9 commented on May 23, 2024

Hi @awwright any updates on this issue?

from jsonschema.

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.