-
Notifications
You must be signed in to change notification settings - Fork 254
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
Required Fields V2 - Conditionally Required Fields #2099
base: main
Are you sure you want to change the base?
Conversation
…ricts them to anyOf, allOf, oneOf which are all a list of fieldKeys
hi @nick-Ag - I know this is still in draft, so just out of curiosity what will this do?
Will it hide or show fields in the UI depending on which fields have a mapping populated? Keen to understand the intent here as I think the second approach would be really valuable. |
Planning on the second approach primarily. I also want the validation to appear in the UX so that users can't save mappings where the group condition has not been met. Looking forward to showing more soon! |
New required fields detectedWarning Your PR adds new required fields to an existing destination. Adding new required settings/mappings for a destination already in production requires updating existing customer destination configuration. Ignore this warning if this PR is for a new destination with no active customers in production. The following required fields were added in this PR:
Add these new fields as optional instead and assume default values in |
…ld defined for one field.
…Adds a new unit test for multiple object dependant conditions
… parameter which fixes 3 unit tests
…ot tests. generates snapshots
…so a snapshot test
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2099 +/- ##
==========================================
+ Coverage 78.58% 79.05% +0.47%
==========================================
Files 1030 1083 +53
Lines 18184 20912 +2728
Branches 3431 4187 +756
==========================================
+ Hits 14290 16533 +2243
- Misses 2752 3231 +479
- Partials 1142 1148 +6 ☔ View full report in Codecov by Sentry. |
@@ -53,6 +53,15 @@ const action: ActionDefinition<Settings, Payload> = { | |||
else: { '@path': '$.properties.last_name' } | |||
} | |||
}, | |||
required: { |
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.
Would this not break current implementation because you are making this field required in certain instances where it wasn't before?
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.
It won't break anything existing because we already throw an error in the case where operation: create
and last_name
is missing. So for event delivery it shifts the error to AJV instead.
In the UI this is currently unenforced, so users can still save a mapping where last_name
is missing
hi @nick-Ag I can't wait to start using this new feature :). |
Hi @nick-Ag , qq:
|
|
I'm going to make a small update to the PR to handle |
This PR revamps the
required
property for action input fields such that a destination builder can define conditionally required fields. These builder defined conditional requirements are then compiled into a JSONSchema4 object, which is used to validate each mapping before theperform
block is triggered.SDD: Link
Conditional Field Example:
For example, the Salesforce Lead
last_name
field is only required when a user is creating a lead. We can now encode that in the definition of the field directly like this:This builder defined condition will then be compiled into a JSONSchema like this:
And eventually will validate Payloads such as these:
{ operation: 'create', first_name: 'nick' } // invalid - missing last_name
{ operation: 'create', last_name: 'aguilar' } // valid - required last_name is included
{ operation: 'update', first_name: 'nick' } // valid - last_name is not required
Reviewing this PR:
~2800 lines added:
Testing
Deployed successfully to staging. I have updated the Salesforce Lead action's
last_name
field with a conditional requirement.As of now these conditions are not implemented in the UI, and I am only expecting new AJV error messages when the conditional requirement is not met.
The conditional requirement is enforced when
operation: create
butlast_name
is missing:When
operation: create
andlast_name
is defined, the condition is met and event delivery succeeds:When
operation: update
the condition is not enforced andlast_name
can be undefined:Merge & Deploy Timing
This PR will be a part of a series of PRs. It should not be merged or deployed before these other PRs are ready.
@joe-ayoub-segment - I will handle the final deploy of this one
app
: TODO 🚧action-cli
: https://github.com/segmentio/action-cli/pull/196 💬