Type-Safe Client Logic Check
Challenge on lesson: Checkpoint: Type-Safe Client Logic
CHALLENGE
Difficulty: intermediate+25 XP
Implement three typing-discipline helpers:
1. isUser(v) โ RETURN true only when v is an object (not null, not array) with a string id, string email containing "@", and optional string name (absent or string).
2. parseWith(v, validator, fallback) โ RETURN { ok: true, value } when validator(v) is true, else { ok: false, fallback }.
3. handleApi(result) โ result is { ok: true, data } or { ok: false, status }. RETURN the data string when ok, else "HTTP " + status. It must never read .data on a failure object.
Press Submit to check your solution.
Back to lesson: Checkpoint: Type-Safe Client Logic