Skip to content

Add InputValidator utility for score range checks - #57

Merged
dmccoystephenson merged 1 commit into
mainfrom
feat/input-validator
Oct 2, 2026
Merged

dmccoystephenson merged 1 commit into
mainfrom
feat/input-validator

Conversation

@dmccoystephenson

Copy link
Copy Markdown
Member

Summary

  • A util/InputValidator utility class is added with isValidScore(int) and areValidScores(Integer...) (null entries, i.e. options not given, are ignored), plus MIN_SCORE/MAX_SCORE constants.
  • The three separate 1-5 range checks are replaced with calls to it: the interactive per-prompt check and the final all-scores check in CreateProjectCommand, and the private isOutOfRange helper in UpdateProjectCommand (removed).
  • User-facing behavior and messages are unchanged; no documentation required updating.

Closes #8

Note on "w/ Jakarta" in the issue title: the issue body asks for an InputValidator utility class that ensures all score inputs are between 1-5, which this PR delivers. Jakarta Bean Validation was not adopted, because it would add a spring-boot-starter-validation dependency to build.gradle (a do-not-auto-merge path) and the shell commands already validate their arguments before reaching the service layer. If annotation-based validation is still wanted, the issue can be reopened or a follow-up filed.

Test plan

  • ./gradlew test on JDK 21: 141 tests executed, 0 failures, 0 errors, 0 skipped (counted from build/test-results/test/*.xml)
  • New InputValidatorTest (5 tests): in-range, out-of-range including Integer.MIN_VALUE/MAX_VALUE, mixed batches and null handling
  • Existing CreateProjectCommandTest and UpdateProjectCommandTest range-rejection tests still pass unchanged

Deferred issues

This PR description was drafted during a Gardener session (https://github.com/Stephenson-Software/gardener).

🤖 Generated with Claude Code


drafted by Claude on behalf of Daniel Stephenson

The 1-5 score range was checked separately in three places across the
create and update commands. Both commands now share InputValidator.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Oct 2, 2026

Copy link
Copy Markdown

Test Results

141 tests  +5   141 ✅ +5   1s ⏱️ ±0s
 21 suites +1     0 💤 ±0 
 21 files   +1     0 ❌ ±0 

Results for commit 5eeb77f. ± Comparison against base commit 784e3c5.

@dmccoystephenson

Copy link
Copy Markdown
Member Author

Self-review rubric (PR #57):

  • Scope: PASS — 4 files: the new InputValidator, its test, and the two commands whose range checks it replaces; no unrelated churn (git diff --stat: +86/-8).
  • Tests-new: PASS — isValidScore and areValidScores are each exercised by InputValidatorTest (5 tests, including boundary, extreme-int and null cases).
  • Tests-fix: N/A — refactor with no behavior change; the existing range-rejection tests in CreateProjectCommandTest and UpdateProjectCommandTest pass unchanged against the new code path.
  • Sibling structure: PASS — placed in util/ beside ConsoleInputProvider; Javadoc style matches it; the test mirrors the package.
  • Sibling renames: N/A — nothing renamed; the private isOutOfRange helper was removed with its only call site.
  • Docs: PASS — README's "a score outside 1-5 is rejected" and the create prompt wording still describe behavior exactly; CONTRIBUTING's ./gradlew test is unchanged.
  • Issue resolution: PASS with a caveat — Input validation w/ Jakarta #8's body (an InputValidator utility that ensures scores are 1-5) is met; the title's "w/ Jakarta" was intentionally not adopted, as explained in the PR body, because it would require a build.gradle dependency.
  • Manual validation: PASS — local ./gradlew test on JDK 21 executed 141 tests, 0 failures; CI test, build (21) and Test Results are green on the PR head.
  • Shell command tests: PASS — both changed @ShellComponent classes keep their *CommandTest coverage of the rejection path.
  • Round-trip coverage: N/A — no Project field changed.
  • I/O behind an interface: N/A — no new I/O.

Findings:

  • src/main/java/com/preponderous/parpt/command/CreateProjectCommand.java:61 and UpdateProjectCommand.java:42 — the user-facing messages still hardcode "1 and 5" instead of deriving from InputValidator.MIN_SCORE/MAX_SCORE, so a future range change would need the messages edited by hand. Left as-is deliberately: the messages are asserted verbatim in tests and README, and the range is not expected to change; noted as a judgment call rather than fixed.

Summary: a behavior-preserving consolidation of the score range check, with CI and the local suite green.

This review was drafted during a Gardener session (https://github.com/Stephenson-Software/gardener).


drafted by Claude on behalf of Daniel Stephenson

@dmccoystephenson
dmccoystephenson merged commit 151b2dd into main Oct 2, 2026
3 checks passed
@dmccoystephenson
dmccoystephenson deleted the feat/input-validator branch October 2, 2026 07:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Input validation w/ Jakarta

1 participant