Skip to content

Commit

Permalink
fix: validate each individual attribute #119
Browse files Browse the repository at this point in the history
  • Loading branch information
jordanjones243 committed Dec 27, 2024
1 parent 5f5dee5 commit 12cd89c
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions packages/form-validation/src/validation.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,15 @@ export default class AuroFormValidation {
elem.validity = 'badInput';
elem.setCustomValidity = elem.setCustomValidityBadInput || '';
}
} else if (elem.value && elem.value.length > 0 && elem.value.length < elem.minLength) {
}

// Length > 0 is required to prevent the error message from showing when the input is empty
if (elem.value?.length > 0 && elem.value?.length < elem.minLength) {
elem.validity = 'tooShort';
elem.setCustomValidity = elem.setCustomValidityTooShort || '';
} else if (elem.value && elem.value.length > elem.maxLength) {
}

if (elem.value?.length > elem.maxLength) {
elem.validity = 'tooLong';
elem.setCustomValidity = elem.setCustomValidityTooLong || '';
}
Expand Down

0 comments on commit 12cd89c

Please sign in to comment.