Skip to content

Commit

Permalink
🐛 [open-formulieren/open-forms#3612] Check both min and max limits if…
Browse files Browse the repository at this point in the history
… both are present
  • Loading branch information
SilviaAmAm committed Nov 21, 2023
1 parent 26a18f2 commit b0ad054
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/formio/validators/minMaxDateValidator.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@ const validateDateBoundaries = (minBoundary, maxBoundary, value) => {

const parsedValue = new Date(value);

if (minDate && maxDate) {
const isValid = parsedValue >= minDate && parsedValue < maxDate;
let errorKeys = isValid ? [] : parsedValue < minDate ? ['minDate'] : ['maxDate'];
return {isValid, errorKeys};
}

if (minDate) return {isValid: parsedValue >= minDate, errorKeys: ['minDate']};
if (maxDate) return {isValid: parsedValue < maxDate, errorKeys: ['maxDate']};
};
Expand Down

0 comments on commit b0ad054

Please sign in to comment.