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
Validate method #77
Comments
As you see here: https://github.com/zaggino/z-schema/blob/master/src/ZSchema.js#L110-L141 |
There's a method |
This should be probably put into a README |
Yes it would help green fingers like me, I am migrating a system to version 3 and our current use with 2 is the following. During load up of our server we validate and then compile schemas (async) However with version 3 I can use just the validate method to do both tasks, however how will I resolve the $ref flag? What does the 'ignoreUnresolvableReferences' option do? Will it resolve them if set to true or will it not validate that property on schema? Best regards |
Ideally you should load all schemas into an array and then pass this array into |
Ok I tried that but I am getting '__$refResolved' undefined. See one of the objects being returned by validate method { properties:
{ ccySID: { type: 'string', format: 'sid', collection: 'currency' },
altCcySubunit: { type: 'string' },
numericCode: { type: 'integer' },
smallestNote:
{ '$ref': 'http://localhost:1234/amt',
'__$refResolved': undefined },
smallestTradedAmount:
{ '$ref': 'http://localhost:1234/amt',
'__$refResolved': undefined },
category: { type: 'string', format: 'lookup', lutype: 'category' },
displayOnWebsite: { type: 'boolean' },
displayOnScreens: { type: 'boolean' },
displaySequence: { type: 'integer' },
isNotTraded: { type: 'boolean' },
flag:
{ '$ref': 'http://localhost:1234/image',
'__$refResolved': undefined },
control:
{ '$ref': 'http://localhost:1234/control',
'__$refResolved': undefined } },
required:
[ 'sid',
'altCcySubunit',
'numericCode',
'smallestNote',
'smallestTradedAmount',
'category',
'displaySequence',
'flag' ],
title: 'collection schema for currency',
additionalProperties: false,
type: 'object' } |
You need to validate schemas with given |
Update I have tried removing ignoreUnresolvableReferences so values is false and have tried setting 'breakOnFirstError' to true however it doesn't break on first error and contains errors regarding $ref issues like this one
|
Do you have a schema with an id |
No |
Then where'd you expect $ref |
See this example from tests, notice the
|
Ok thank you, do I need to this as separate arrays for each of my schemas that are embedded? |
You can put all of your schemas into one array and validator will take care of the rest. They don't even need to be in any specific order. |
Ok thanks |
Leaving this open to update the README |
Let me know if you need any help with documentation! |
Hi
When you use the validate method does it compile schemas too? If not what method do I need to use to compile schemas?
Thanks
The text was updated successfully, but these errors were encountered: