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
Add support for array input for all constraints in HangingProtocolService validator #3322
Conversation
✅ Deploy Preview for ohif-platform-viewer canceled.
|
✅ Deploy Preview for ohif-platform-docs ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
} | ||
// We need to compare each element in the array | ||
else { | ||
if (JSON.stringify(testValue) !== JSON.stringify(value)) { |
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.
Please iterate over each item and return the information about which element is different. Also, stringify is slow and this can be called many times in order to determine which stage and which hanging display set to apply.
if (testValue[0] === value) { | ||
return `${key} must not be ${testValue}`; | ||
} | ||
} else if (JSON.stringify(testValue) === JSON.stringify(value)) { |
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.
Ditto about stringify.
Codecov Report
@@ Coverage Diff @@
## master #3322 +/- ##
==========================================
+ Coverage 38.27% 42.81% +4.53%
==========================================
Files 82 82
Lines 1348 1448 +100
Branches 303 337 +34
==========================================
+ Hits 516 620 +104
Misses 666 666
+ Partials 166 162 -4
Continue to review full report in Codecov by Sentry.
|
* = ['abc', 'def', 'dog'] (Valid) | ||
* = ['cat', 'dog'] (Fail) | ||
* | ||
* value = 'Attenuation Corrected' (Fail) |
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.
This case should be equivalent to ['Attenuation Corrected'], which should pass if the testValue contains the same identical string.
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.
Could you add the two edge cases I described - the issue is that for the DICOM library we are using, it converts to/from single item arrays, so on the equals and the other one I commented on,
['abc'] and 'abc'
should be treated equivalently, both for the test value and the original value.
…COM is always an array and fix includes and doesNotIncludes validators
…lidator # Conflicts: # platform/core/src/services/HangingProtocolService/lib/validator.js # platform/core/src/services/HangingProtocolService/lib/validator.test.js
✅ Deploy Preview for ohif-dev ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
|
||
- | Rule | Single Value | Array Value | Example | | ||
|--- |--- |--- |--- | | ||
| equals | === | All members are === in same order | value = ['abc', 'def', 'GHI']<br>testValue = 'abc' (Fail)<br><br> = ['abc'] (Fail)<br><br> = ['abc', 'def', 'GHI'] (Valid)<br><br> = ['abc', 'GHI', 'def'] (Fail)<br><br> = ['abc', 'def'] (Fail)<br><br>value = 'Attenuation Corrected'<br>testValue = 'Attenuation Corrected' (Valid)<br> = 'Attenuation' (Fail)<br> | |
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 believe the tests are failing on how the <br>
tag is used - I suspect you need to use
as a closed tag value (XHTML syntax). Try building hte docs locally to test.
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.
Will approve as soon as hte build is fixed.
Dear @wayfarer3130 should be good ? |
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.
Now passing the tests so good to go.
Context
This PR updates the validator.js file in the Hanging Protocol Service library to allow constraints to accept an array of values. Previously, only the contains constraint could accept an array.
Changes & Results
-Updated functions to accept an array of values.
-Made changes to ensure all constraints accept an array of values for consistency.
Constraint Rules
testValue = 'abc' (Fail)
= ['abc'] (Fail)
= ['abc', 'def', 'GHI'] (Valid)
= ['abc', 'GHI', 'def'] (Fail)
= ['abc', 'def'] (Fail)
value = 'Attenuation Corrected'
testValue = 'Attenuation Corrected' (Valid)
= 'Attenuation' (Fail)
value = ['Attenuation Corrected']
testValue = ['Attenuation Corrected'] (Valid)
= 'Attenuation Corrected' (Valid)
= 'Attenuation' (Fail)
testValue = 'abc' (Valid)
= ['abc'] (Valid)
= ['abc', 'def', 'GHI'] (Fail)
= ['abc', 'GHI', 'def'] (Valid)
= ['abc', 'def'] (Valid)
value = 'Attenuation Corrected'
testValue = 'Attenuation Corrected' (Fail)
Valid
= 'Attenuation' (Valid)
value = ['Attenuation Corrected']
testValue = ['Attenuation Corrected'] (Fail)
= 'Attenuation Corrected' (Fail)
= 'Attenuation' (Fail)
testValue = ['abc'] (Valid)
= ‘abc’ (Fail)
= [‘abc’] (Fail)
= ‘dog’ (Fail)
= = [‘att’, ‘abc’] (Valid)
= ['abc', 'def', 'dog'] (Valid)
= ['cat', 'dog'] (Fail)
value = 'Attenuation Corrected'
testValue = ['Attenuation Corrected', 'Corrected'] (Valid)
= ['Attenuation', 'Corrected'] (Fail)
value = ['Attenuation Corrected']
testValue = 'Attenuation Corrected' (Fail)
= ['Attenuation Corrected', 'Corrected'] (Valid)
= ['Attenuation', 'Corrected'] (Fail)
testValue = ‘Corr’ (Valid)
= ‘abc’ (Fail)
= [‘att’, ‘cor’] (Valid)
= ['abc', 'def', 'dog'] (Fail)
value = 'Attenuation Corrected'
testValue = ['Attenuation Corrected', 'Corrected'] (Fail)
= ['Attenuation', 'Corrected'] (Valid)
value = ['Attenuation Corrected']
testValue = 'Attenuation' (Fail)
= ['Attenuation Corrected', 'Corrected'] (Fail)
= ['Attenuation', 'Corrected'] (Valid)
testValue = ‘Corr’ (Valid)
= ‘corr’ (Valid)
= [‘att’, ‘cor’] (Valid)
= [‘Att’, ‘Wall’] (Valid)
= [‘cat’, ‘dog’] (Fail)
value = ['abc', 'def', 'GHI']
testValue = 'def' (Valid)
= 'dog' (Fail)
= ['gh', 'de'] (Valid)
= ['cat', 'dog'] (Fail)
testValue = ‘Corr’ (Valid)
= ‘corr’ (Fail)
= [‘att’, ‘cor’] (Fail)
= [‘Att’, ‘Wall’] (Valid)
= [‘cat’, ‘dog’] (Fail)
value = ['abc', 'def', 'GHI']
testValue = 'def' (Valid)
= 'dog' (Fail)
= ['cat', 'de'] (Valid)
= ['cat', 'dog'] (Fail)
testValue = ‘Corr’ (Fail)
= ‘corr’ (Valid)
= [‘att’, ‘cor’] (Valid)
= [‘Att’, ‘Wall’] (Fail)
= [‘cat’, ‘dog’] (Valid)
value = ['abc', 'def', 'GHI']
testValue = 'def' (Fail)
= 'dog' (Valid)
= ['cat', 'de'] (Fail)
= ['cat', 'dog'] (Valid)
testValue = ‘Corr’ (Fail)
= ‘corr’ (Fail)
= [‘att’, ‘cor’] (Fail)
= [‘Att’, ‘Wall’] (Fail)
= [‘cat’, ‘dog’] (Valid)
value = ['abc', 'def', 'GHI']
testValue = 'DEF' (Fail)
= 'dog' (Valid)
= ['cat', 'gh'] (Fail)
= ['cat', 'dog'] (Valid)
testValue = ‘Corr’ (Fail)
= ‘Att’ (Fail)
= ['cat', 'dog', 'Att'] (Valid)
= [‘cat’, ‘dog’] (Fail)
testValue = ‘TED’ (Fail)
= ‘ted’ (Valid)
= ['cat', 'dog', 'ted'] (Valid)
= [‘cat’, ‘dog’] (Fail)
testValue = 20 (Valid)
= 40 (Fail)
testValue = 40 (Valid)
= 20 (Fail)
testValue = [10,60] (Valid)
= [60, 10] (Valid)
= [0, 10] (Fail)
= [70, 80] (Fail)
= 45 (Fail)
= [45] (Fail)
Testing
Checklist
PR
semantic-release format and guidelines.
Code
etc.)
Public Documentation Updates
additions or removals.
Tested Environment