Skip to content

Commit

Permalink
EZP-28646: Validation alert for map location which is not required
Browse files Browse the repository at this point in the history
  • Loading branch information
Piotr Nalepa committed Dec 21, 2017
1 parent bfff82b commit d489101
Showing 1 changed file with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,14 @@
const result = { isError: false };
const label = input.closest('.ez-data-source__field').querySelector('.ez-data-source__label').innerHTML;
const isNumber = !isNaN(value);
const isInRange = (value <= max && value >= min);
const isCorrectValue = isNumber && (value <= max && value >= min);

if (!input.required && isCorrectValue) {
if (!input.required && isNumber && isInRange) {
return result;
}

if (!isCorrectValue) {
if (isNumber && !isInRange) {
result.isError = true;
result.errorMessage = window.eZ.errors.outOfRangeValue
.replace('{fieldName}', label)
Expand All @@ -35,7 +36,7 @@
return result;
}

if (isNaN(value)) {
if (input.required && !isNumber) {
result.isError = true;
result.errorMessage = window.eZ.errors.emptyField.replace('{fieldName}', label);
}
Expand Down

0 comments on commit d489101

Please sign in to comment.