This repository has been archived by the owner on Jan 4, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
fix: building indices on arrays using prefixItems #343
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
shumkov
reviewed
Aug 31, 2021
@@ -189,8 +189,14 @@ module.exports = function validateDataContractFactory( | |||
|
|||
if (propertyType === 'array' && !isByteArray) { | |||
const { items, prefixItems } = propertyDefinition; | |||
|
|||
if (prefixItems || items.type === 'object' || items.type === 'array') { | |||
if (prefixItems && prefixItems.length) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess empty prefixItems
must be invalidated by schema validation.
This pull request introduces 1 alert when merging da12217 into 2b0a86a - view on LGTM.com new alerts:
|
shumkov
reviewed
Aug 31, 2021
Comment on lines
192
to
199
if (prefixItems) { | ||
if ( | ||
prefixItems.some((prefixItem) => prefixItem.type === 'object' || prefixItem.type === 'array') | ||
|| !prefixItems.every((prefixItem) => prefixItem.type === prefixItems[0].type) | ||
) { | ||
invalidPropertyType = 'array'; | ||
} | ||
} else if (items.type === 'object' || items.type === 'array') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggested change
if (prefixItems) { | |
if ( | |
prefixItems.some((prefixItem) => prefixItem.type === 'object' || prefixItem.type === 'array') | |
|| !prefixItems.every((prefixItem) => prefixItem.type === prefixItems[0].type) | |
) { | |
invalidPropertyType = 'array'; | |
} | |
} else if (items.type === 'object' || items.type === 'array') { | |
const isInvalidPrefixItems = prefixItems && | |
( | |
prefixItems.some((prefixItem) => prefixItem.type === 'object' || prefixItem.type === 'array') || | |
!prefixItems.every((prefixItem) => prefixItem.type === prefixItems[0].type) | |
); | |
const isInvalidItemTypes = items.type === 'object' || items.type === 'array'; | |
if (isInvalidPrefixItems || isInvalidItemTypes) { |
shumkov
approved these changes
Aug 31, 2021
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch! 👍
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Issue being fixed or feature implemented
DPP throws an error when you try to use index on arrays using prefixItems keyword #275
What was done?
How Has This Been Tested?
With unit tests
Breaking Changes
No
Checklist:
For repository code-owners and collaborators only