Skip to content

Commit f70a327

Browse files
committed
Fix Stimulus validation: show all field errors, not just first one
Changed 'else if' to 'if' so both Author and Text validation errors display when both fields are empty. Removed unreachable else block. Fixes 4 failing Stimulus/Turbo RSpec tests.
1 parent fac506d commit f70a327

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

client/app/controllers/comments_controller.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,8 @@ export default class extends Controller {
2222
errorList.innerHTML = '';
2323
if (!inputAuthor.value) {
2424
errors.push('Author');
25-
} else if (!inputText.value) {
26-
errors.push('Text');
27-
} else {
28-
errors.push('Author');
25+
}
26+
if (!inputText.value) {
2927
errors.push('Text');
3028
}
3129
errors.forEach((error) => {

0 commit comments

Comments
 (0)