Checks the JSON bodies that the account routes (routes/users.ts,
routes/me.ts, routes/sessions.ts) receive before they read them.
Returns obj[key] when obj is an object that has it, else undefined. The
users routes whose body has no guard of its own read their fields with it.
Checks whether obj is a LoginUserRequest. It checks the types
only: a wrong name or password is the login route's answer to give.
Checks whether obj is a valid RegisterUserRequest. When it isn't,
validateRegisterUserRequest says why.
Checks whether obj is a valid UpdateUserRequest, for
PATCH /api/me. Every field is optional, but each one present must be
well-formed and within the VALIDATION limits.
Returns what is wrong with a sign-up body, as the message the register page
shows, or null when it is valid. It checks the shape, the email's form, and
the username and password against the VALIDATION limits. Whether the name,
the email or the invite is taken is createUser's and claimInvite's check.
Usage
import * as mod from "api/validators/user.ts";