Skip to content

Commit

Permalink
Merge pull request #267 from ezsystems/EZP-28646-fix-map-validation
Browse files Browse the repository at this point in the history
EZP-28646: Validation alert for map location which is not required
  • Loading branch information
Łukasz Serwatka authored Dec 21, 2017
2 parents e3597cf + f3877f9 commit 41ec736
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@
const result = { isError: false };
const label = input.closest('.ez-data-source__field').querySelector('.ez-data-source__label').innerHTML;
const isNumber = !isNaN(value);
const isCorrectValue = isNumber && (value <= max && value >= min);
const isInRange = (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 +35,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 41ec736

Please sign in to comment.