Make Conditional Logic Schema rule properties required#1576
Merged
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## development #1576 +/- ##
============================================
Coverage 77.82% 77.83%
============================================
Files 255 255
Lines 13899 13902 +3
Branches 370 370
============================================
+ Hits 10817 10820 +3
Misses 3074 3074
Partials 8 8 ☔ View full report in Codecov by Sentry. |
e1bd227 to
4455d2a
Compare
|
Coverage report for commit: f09ef73 Summary - Lines: 92.96% | Methods: 88.24% | Branches: 81.37%
🤖 Jest coverage report |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Coverage report for commit: f09ef73 Summary - Lines: 82.30% | Methods: 88.67%
🤖 PHPUnit coverage report |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Flag the nested conditional logic rule properties (fieldId, operator, value) as required in the REST schema so the API rejects incomplete rules. Add PHPUnit coverage asserting both the schema requirement and that a rule missing a required property is rejected. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
4455d2a to
f09ef73
Compare
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description
The Form Settings REST endpoint accepted conditional logic rules that were missing properties, so a rule could be persisted with, e.g., a
fieldIdandoperatorbut novalue. This flags the three nested rule properties —fieldId,operator, andvalue— asrequiredin the REST schema forconditionalLogic.rules.items, so the API now rejects incomplete rules with a400 rest_property_requirederror instead of silently storing a malformed rule.Changes:
src/Helper/Helper_Options_Fields.php— add'required' => trueto thefieldId,operator, andvalueproperties of the conditional logic rule schema.tests/phpunit/integration/Rest/Test_Rest_Form_Settings.php— assert the schema marks each rule property required, and add a test confirming a POST with a rule missingvalueis rejected with400 rest_property_required.Testing instructions
POSTto/gravity-pdf/v1/form/{form_id}with aconditionalLogicpayload whoserulesentry omits one offieldId,operator, orvalue, e.g.:{ "name": "Label", "template": "rubix", "conditionalLogic": { "actionType": "show", "logicType": "any", "rules": [ { "fieldId": "7", "operator": "is" } ] } }400with coderest_property_requiredforconditionalLogic(previously this was accepted).Or run the PHPUnit coverage:
Screenshots
Checklist:
Additional Comments