-
-
Notifications
You must be signed in to change notification settings - Fork 865
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
If/then/else doesn't seem to work correctly #770
Comments
See https://runkit.com/esp/5ae23d12d0320b001260cdb3 You must be running some old version that doesn't have if/then/else, as otherwise explicitly adding draft-07 meta-schema would throw an exception. Also "id" should be "$id" in draft-07 |
Thanks for your help, Evgeny. I can see that the code runs correctly in runkit. Nevertheless the if/then/else logic is skill skipped when I run locally with an app I created using ‘npx create-react-app’. Npm list shows only the latest version of ajv.
npm list
/Users/Mark/React
├─┬ ajv@6.4.0
│ ├── fast-deep-equal@1.1.0
│ ├── fast-json-stable-stringify@2.0.0
│ ├── json-schema-traverse@0.3.1
│ └─┬ uri-js@3.0.2
│ └── punycode@2.1.0
├── json-loader@0.5.7
├─┬ json-pointer@0.6.0
│ └── foreach@2.0.5
├── json-schema@0.2.3
└── jsonschema@1.2.4
Off the top of your head can you think of anything that might be going wrong? I’ve scoured the web for hours without finding a clue.
Mark
From: Evgeny Poberezkin <notifications@github.com>
Reply-To: epoberezkin/ajv <reply@reply.github.com>
Date: Thursday, April 26, 2018 at 5:05 PM
To: epoberezkin/ajv <ajv@noreply.github.com>
Cc: "Mueller, Mark" <Mark.Mueller@LibertyMutual.com>, Author <author@noreply.github.com>
Subject: Re: [epoberezkin/ajv] If/then/else doesn't seem to work correctly (#770)
See https://runkit.com/esp/5ae23d12d0320b001260cdb3
You must be running some old version that doesn't have if/then/else, as otherwise explicitly adding draft-07 meta-schema would throw an exception.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub<#770 (comment)>, or mute the thread<https://github.com/notifications/unsubscribe-auth/Ak-MLwQ3yef7KvldJgbxXjsilJ58NQZ9ks5tsjY5gaJpZM4TnhJk>.
|
FYI,
ajv test -s schema.json -d testjson.json –-invalid. Works correctly.
Runkit works correctly.
But running using npm gives me:
Error: no schema with key or ref "http://json-schema.org/draft-07/schema#"
Even though I can’t see how I could be getting the wrong version of ajv.
Mark
From: Evgeny Poberezkin <notifications@github.com>
Reply-To: epoberezkin/ajv <reply@reply.github.com>
Date: Thursday, April 26, 2018 at 5:05 PM
To: epoberezkin/ajv <ajv@noreply.github.com>
Cc: "Mueller, Mark" <Mark.Mueller@LibertyMutual.com>, Author <author@noreply.github.com>
Subject: Re: [epoberezkin/ajv] If/then/else doesn't seem to work correctly (#770)
See https://runkit.com/esp/5ae23d12d0320b001260cdb3
You must be running some old version that doesn't have if/then/else, as otherwise explicitly adding draft-07 meta-schema would throw an exception.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub<#770 (comment)>, or mute the thread<https://github.com/notifications/unsubscribe-auth/Ak-MLwQ3yef7KvldJgbxXjsilJ58NQZ9ks5tsjY5gaJpZM4TnhJk>.
|
I suspect it may be related to #708, which is npm issue with sub-dependencies. Maybe using yarn will help? |
Try this: require('ajv');
console.log(Object.keys(require.cache).filter(s => s.includes('ajv'))) After that you can check the version of Ajv in package.json in the folder where you get it from. |
Also, look at the full |
Thank you for all your help, Evgeney! I have it working. My problem was that I was using create-react-app and did not want to use yarn, but now it works.
Mark
From: Evgeny Poberezkin <notifications@github.com>
Reply-To: epoberezkin/ajv <reply@reply.github.com>
Date: Saturday, April 28, 2018 at 6:34 AM
To: epoberezkin/ajv <ajv@noreply.github.com>
Cc: "Mueller, Mark" <Mark.Mueller@LibertyMutual.com>, Author <author@noreply.github.com>
Subject: Re: [epoberezkin/ajv] If/then/else doesn't seem to work correctly (#770)
Also, look at the full npm ls output - there can be two versions...
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub<#770 (comment)>, or mute the thread<https://github.com/notifications/unsubscribe-auth/Ak-ML2Ik403Mz0Sos1O-1gFxsP4SfzK6ks5ttEVkgaJpZM4TnhJk>.
|
What version of Ajv are you using? Does the issue happen if you use the latest version?
6.4.0
Ajv options object
JSON Schema
Sample data
Your code
Validation result, data AFTER validation, error messages
Validation: It's good!
What results did you expect?
expected error: required key [price] not found
This is what the java library, everit-org/json-schema, returns.
Are you going to resolve the issue?
I don't have the expertise.
The text was updated successfully, but these errors were encountered: