IP Validator
Level: Beginner 15–30 minConcepts: Validation
Solutions: C# | TypeScript | Python
Create a class with one method called ValidateIpv4Address. The method takes a string and return true if it is valid host assignable IP address and false if not.
IPv4 addresses are 32 bits long and grouped into 4 one byte blocks separated by dotted-decimal notation. E.g. 192.168.1.1.
Most IP addresses ending in 0 represent the entire network segment and cannot be used as host addresses. And most IP addresses ending in 255 represent a broadcast address and cannot be used as a host address. There are exceptions, when using subnets, for the sake of this Kata any address ending in 0 or 255 is not a valid host address.
NOTE
DO NOT USE REGULAR EXPRESSIONS TO SOLVE THIS KATA.
Examples
| IP Address | Result |
|---|---|
| 1.1.1.1 | true |
| 192.168.1.1 | true |
| 10.0.0.1 | true |
| 127.0.0.1 | true |
| 192.168.1.0 | true |
| 0.0.0.0 | false |
| 255.255.255.255 | false |
| 10.0.1 | false |
| 192.168.01.1 | false |
| 192.168.1.00 | false |
Solutions
You can find all language solutions here IP Validator Solutions
Or you can select a specific language below.
Reference Walkthrough
Reference implementations in C#, TypeScript, and Python live at tddbuddy-reference-katas/ip-validator. Eighteen shared scenarios cover the full rule cascade — valid host addresses (1.1.1.1, 192.168.1.1, 10.0.0.1, 127.0.0.1), the two non-host endings (0 and 255), wrong octet counts, leading zeros, out-of-range octets, non-digit characters, empty octets, and the empty string — satisfied identically across all three languages.
- C# (.NET 8, xUnit, FluentAssertions 6.12.0) — walkthrough
- TypeScript (Node 20, Vitest 1.6, TS 5 strict) — walkthrough
- Python (3.11, pytest) — walkthrough
This kata ships in Agent Full-Bake mode at high gear (F1 tier): the algorithm is small enough to land as one commit per language, with a brief walkthrough noting there are no builders because the algorithm’s inputs and outputs are the domain. IPv6 is intentionally out of scope — the TDD Buddy spec is IPv4-only. No regular expressions, per the prompt: each language hand-rolls the digit scan, which makes the leading-zero and negative-sign rejections fall out of the character loop rather than a regex dialect quirk.
Spec conflict note. The Examples table above lists 192.168.1.0 → true, which contradicts both the prose rule (“any address ending in 0 or 255 is not a valid host address”) and the 0.0.0.0 → false / 255.255.255.255 → false rows. The reference implementations follow the prose rule — any address whose final octet is 0 or 255 is rejected. See the repo’s Gears section for when high gear is the right call.
Related reading
- Examples Pin Intent. Properties Pin the Invariants.
Example-based tests anchor scenarios in the team's vocabulary. Property-based tests anchor invariants across the input space. The agent needs both axes, and most suites only carry one. - The Test Pyramid Was an Economic Argument
The test pyramid was not a quality law. It was a cost structure: unit tests were cheap, integration tests were expensive, so you wrote many of the first and few of the second. Agents collapsed the cost of writing tests at every level, and the cheapest test that still tells the truth is the one that pins a seam the agent cannot fake. - Agents Amplify Whatever Vocabulary They Find
Agents do not bring vocabulary to your codebase. They mirror what's already there. Strong vocabulary gets agent contributions that read like the team. Weak vocabulary gets faster mediocrity. The work you did for craft reasons just became leverage.