JSON Settings Checker
Build a Scala command-line tool that checks an application's JSON settings file before it's used, and explains exactly what's wrong. Instead of a vague "invalid config", it prints precise messages such as server.port: must be between 1 and 65535, got 70000, or database.url: missing required field, and reports every problem at once instead of stopping at the first. It's a good first Scala project: you'll learn case classes to describe the expected settings, parsing JSON with Circe, collecting validation errors with Cats' Validated, running the program with Cats Effect's IOApp, and testing with munit.
- Estimate
- ~8.5h
- Steps
- 6
- Completed by
- 0
- Proposed by
- codeseed.app
sbt · Cats Effect
Project roadmap
- 01
Define the settings and output
~1hWrite README.md with an example settings file (for example server with host and port, database with url and pool size, and a list of feature flags) and the exact rules for each field. Show the expected output for a valid file and for a file with several mistakes. Create an sbt project with circe-parser, cats-core, cats-effect and munit. Done when: README.md shows the rules and example output.
- 02
Model the settings
~1.5hDefine case classes for the settings (Settings, Server, Database). Write a function that reads a field at a path from a Circe Json value and reports errors with the full path (such as database.poolSize), for missing fields and wrong types (a text where a number is expected). Done when: reading a correct file produces a Settings value, and unit tests show clear errors for missing fields and wrong types.
- 03
Validate and collect all errors
~2hUse ValidatedNel[String, A] for each field's checks (port range, a URL starting with postgres://, pool size between 1 and 100, feature names from a known list) and combine them with mapN, so all errors are collected instead of stopping at the first. Also warn about unknown fields, which are often typos. Done when: a file with 4 mistakes reports all 4 with their paths.
- 04
Build the command
~1.5hWrite an IOApp that reads the file path from the arguments, reads the file (reporting when it's missing or unreadable), parses the JSON (reporting the line and column of syntax errors), and validates it. Print OK or the list of errors, and return exit code 0 when valid and 1 otherwise. Done when: running the tool on valid and invalid files prints the right output and exit code.
- 05
Handle edge cases
~1hHandle an empty file, a file containing a JSON array or number instead of an object, null values, and very large numbers. Add a --json option that prints the errors as JSON, for use in scripts. Done when: each edge case gives a clear message instead of a crash.
- 06
Test it
~1.5hWrite munit tests with sample files in test resources: a valid file, each rule broken on its own, several rules broken together, syntax errors, and unknown fields. Check the exact messages and paths. Done when: sbt test passes.
Resources
Ready to build this?
Get a GitHub repo and start building. Your AI reviewer checks each step as you go.
Tech stack