Skip to content

Commit

Permalink
Merge pull request #443 from ProcessMaker/observation/FOUR-19221
Browse files Browse the repository at this point in the history
changed the custom rules to avoid conflicts
  • Loading branch information
ryancooley authored Nov 8, 2024
2 parents b009cc4 + 2eb809c commit 002232c
Showing 1 changed file with 20 additions and 11 deletions.
31 changes: 20 additions & 11 deletions src/components/mixins/validation.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,19 +119,28 @@ export default {
let data = this.validationData ? this.validationData : { [fieldName]: this.value };
let validationRules = "";

if (typeof this.validation !== "string" && this.validation.length) {
if (Array.isArray(this.validation)) {
let rules = [];

this.validation.forEach((configs) => {
if (!configs.value) {
return;
}
rules.push(configs.value);
const ruleValue = configs.value
.replace('after:', 'after_date:')
.replace('before:', 'before_date:')
.replace('after_or_equal:', 'after_or_equal_date:')
.replace('before_or_equal:', 'before_or_equal_date:');
rules.push(ruleValue);
});

validationRules = rules;
} else {
validationRules = this.validation;
validationRules = this.validation
.replace('after:', 'after_date:')
.replace('before:', 'before_date:')
.replace('after_or_equal:', 'after_or_equal_date:')
.replace('before_or_equal:', 'before_or_equal_date:');
}

let rules = {
Expand Down Expand Up @@ -172,7 +181,7 @@ export default {
);

Validator.register(
"after",
"after_date",
function (date, params) {
// checks if incoming 'params' is a date or a key reference.
let checkDate = moment(params);
Expand All @@ -185,11 +194,11 @@ export default {

return inputDate > afterDate;
},
"The :attribute must be after :after."
"The :attribute must be after :after_date."
);

Validator.register(
"after_or_equal",
"after_or_equal_date",
function (date, params) {
// checks if incoming 'params' is a date or a key reference.
let checkDate = moment(params);
Expand All @@ -202,11 +211,11 @@ export default {

return inputDate >= equalOrAfterDate;
},
"The :attribute must be equal or after :after_or_equal."
"The :attribute must be equal or after :after_or_equal_date."
);

Validator.register(
"before",
"before_date",
function (date, params) {
// checks if incoming 'params' is a date or a key reference.
let checkDate = moment(params);
Expand All @@ -219,11 +228,11 @@ export default {

return inputDate < beforeDate;
},
"The :attribute must be before :before."
"The :attribute must be before :before_date."
);

Validator.register(
"before_or_equal",
"before_or_equal_date",
function (date, params) {
// checks if incoming 'params' is a date or a key reference.
let checkDate = moment(params);
Expand All @@ -236,7 +245,7 @@ export default {

return inputDate <= beforeDate;
},
"The :attribute must be equal or before :before_or_equal."
"The :attribute must be equal or before :before_or_equal_date."
);

Validator.register(
Expand Down

0 comments on commit 002232c

Please sign in to comment.