Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

validateSchema is not a function #2

Closed
zuttedr opened this issue Dec 8, 2023 · 6 comments
Closed

validateSchema is not a function #2

zuttedr opened this issue Dec 8, 2023 · 6 comments

Comments

@zuttedr
Copy link

zuttedr commented Dec 8, 2023

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
Copy link
Owner

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

@zuttedr
Copy link
Author

zuttedr commented Dec 8, 2023

I just followed your readme

import validateSchema from 'xsd-validator'

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

@deltazero-cz
Copy link
Owner

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

@zuttedr
Copy link
Author

zuttedr commented Dec 11, 2023

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
Copy link
Owner

deltazero-cz commented Dec 11, 2023

For pure javascript, try with

const validateSchema = require('xsd-validator')

instead of

import validateSchema from 'xsd-validator'

@zuttedr
Copy link
Author

zuttedr commented Dec 12, 2023

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

@zuttedr zuttedr closed this as completed Dec 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants