deltazero-cz / node-xsd-validator

Validating XMLs against XSD schema
ISC License
0 stars 1 forks source link

validateSchema is not a function #2

Closed zuttedr closed 7 months ago

zuttedr commented 7 months ago

Hi, I've installed the package but when i'm trying to use it, it gives an error "TypeError: validateSchema is not a function". What could be the problem? Thanks

deltazero-cz commented 7 months ago

@zuttedr, can you provide a piece of your code? How is validateSchema imported and called?

zuttedr commented 7 months ago

I just followed your readme

import validateSchema from 'xsd-validator'

// returns true for valid documents validateSchema( myXml, myXmlSchema) // -> true

deltazero-cz commented 7 months ago

Can you give me a little more, like a reproducible example of your code? So far, this should simply work.

zuttedr commented 7 months ago

Well, I just installed it with npm and created a js file containing this code: import validateSchema from 'xsd-validator'

// returns true for valid documents validateSchema("xml", "xml");

I just saw that this is a package for typescript, but want to use it in a nodejs application. Could this be the cause of the problem?

deltazero-cz commented 7 months ago

For pure javascript, try with

const validateSchema = require('xsd-validator')

instead of

import validateSchema from 'xsd-validator'

zuttedr commented 7 months ago

Hi @deltazero-cz , Was able to make it work by calling the function like this: validateSchema["validateSchema"](xml,schema) Thanks for the help