Skip to content

Commit

Permalink
Merge pull request #1479 from ProcessMaker/bugfix/FOUR-11286-next
Browse files Browse the repository at this point in the history
[FOUR-11286] for Next Branch
  • Loading branch information
ryancooley authored Nov 4, 2023
2 parents 83fcac5 + a9dd93e commit da0558d
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 4 deletions.
20 changes: 18 additions & 2 deletions src/mixins/extensions/ValidationRules.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ export default {
console.error("Invalid variable name");
}
} else {
properties[':class'] = `{ 'form-group--error': showValidationErrors && ${this.checkVariableExists('$v.vdata.' + element.config.name)} && $v.vdata.${element.config.name}.$invalid || showValidationErrors && ${this.checkVariableExists('$v.schema.' + element.config.name)} && $v.schema.${element.config.name}.$invalid }`;
properties[':error'] = `showValidationErrors && ${this.checkVariableExists('$v.vdata.' + element.config.name)} && validationMessage($v.vdata.${element.config.name}) || showValidationErrors && ${this.checkVariableExists('$v.schema.' + element.config.name)} && validationMessage($v.schema.${element.config.name})`;
properties[':class'] = `{ 'form-group--error': (showValidationErrors || ${this.fieldValidationShow(element)}) && ${this.checkVariableExists('$v.vdata.' + element.config.name)} && $v.vdata.${element.config.name}.$invalid || (showValidationErrors || ${this.fieldValidationShow(element)}) && ${this.checkVariableExists('$v.schema.' + element.config.name)} && $v.schema.${element.config.name}.$invalid }`;
properties[':error'] = `(showValidationErrors || ${this.fieldValidationShow(element)}) && ${this.checkVariableExists('$v.vdata.' + element.config.name)} && validationMessage($v.vdata.${element.config.name}) || (showValidationErrors || ${this.fieldValidationShow(element)}) && ${this.checkVariableExists('$v.schema.' + element.config.name)} && validationMessage($v.schema.${element.config.name})`;
}
}
},
Expand Down Expand Up @@ -53,5 +53,21 @@ export default {
}, {str: '', variable: ''});
return check.str;
},
fieldValidationShow (element) {
let showError = true;
if (element.config && element.config.validation) {
const validationHidden = ['Required', 'Required if'];
if (Array.isArray(element.config.validation)) {
element.config.validation.forEach((validation) => {
if (validationHidden.includes(validation.content)) {
showError = false;
}
});
} else {
showError = validationHidden.includes(element.config.validation);
}
}
return showError;
}
},
};
17 changes: 15 additions & 2 deletions tests/e2e/specs/ValidationShownOnSubmit.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,14 @@ describe('Validation Rules', () => {
it('Invalid default values', () => {
cy.loadFromJson('validation_rules.json', 0);
cy.get('[data-cy=mode-preview]').click();

cy.shouldNotHaveValidationErrors('screen-field-form_input_1');

cy.shouldHaveValidationErrors('screen-field-form_checkbox_1');
cy.shouldHaveValidationErrors('screen-field-form_input_1');
cy.shouldHaveValidationErrors('screen-field-form_input_2');
cy.shouldNotHaveValidationErrors('screen-field-form_input_3');
cy.shouldHaveValidationErrors('screen-field-form_input_4');
cy.shouldNotHaveValidationErrors('screen-field-form_input_5');
cy.shouldNotHaveValidationErrors('screen-field-form_input_6');

cy.get('[data-cy=preview-content] .page button').click();

Expand All @@ -19,6 +25,13 @@ describe('Validation Rules', () => {
cy.get('[data-cy=preview-content] [data-cy="screen-field-form_input_1"]')
.clear()
.type('on');

cy.shouldHaveValidationErrors('screen-field-form_checkbox_1');
cy.shouldNotHaveValidationErrors('screen-field-form_input_1');
cy.shouldHaveValidationErrors('screen-field-form_input_2');
cy.shouldNotHaveValidationErrors('screen-field-form_input_3');
cy.shouldHaveValidationErrors('screen-field-form_input_4');
cy.shouldNotHaveValidationErrors('screen-field-form_input_5');
cy.shouldNotHaveValidationErrors('screen-field-form_input_6');
});
});

0 comments on commit da0558d

Please sign in to comment.