Skip to content

Fix The "Required IF" validation doesn't works in Loop/Record List [FOUR-4132]#1094

Merged
caleeli merged 11 commits intodevelopfrom
bugfix/ticket-1122
Oct 28, 2021
Merged

Fix The "Required IF" validation doesn't works in Loop/Record List [FOUR-4132]#1094
caleeli merged 11 commits intodevelopfrom
bugfix/ticket-1122

Conversation

@caleeli
Copy link
Copy Markdown
Collaborator

@caleeli caleeli commented Oct 26, 2021

Fixes: https://processmaker.atlassian.net/browse/FOUR-4132
Ticket: http://tickets.pm4overflow.com/tickets/1122

This PR based on #1089 includes:

  • Get the validation rules data context including reference to _parent
  • Add test using validations in Loops and using reference to _parent

@caleeli caleeli marked this pull request as ready for review October 27, 2021 14:16
@eiresendez eiresendez self-requested a review October 28, 2021 13:57
loopField['$each'] = [];
const firstRow = this.data[0] || {};
loopField['$each'] = {};
const firstRow = (get(this.data, this.element.config.name) || [{}])[0];
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the get from lodash has a default value if the conditional is not valid or the value is not present.
Docs: https://lodash.com/docs/4.17.15#get

Suggested change
const firstRow = (get(this.data, this.element.config.name) || [{}])[0];
const firstRow = get(this.data, this.element.config.name, [{}][0]);

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the suggestion, but I use || [{}] to cover the case in which get(this.data, this.element.config.name) is defined but is null

@caleeli caleeli merged commit 3696f8b into develop Oct 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants