mimukit/saasaloy/saasaloy-validators

Claude Code and agent skill by mimukit/saasaloy

Trust tier 3
  • community
Source check pending

Checking that the SKILL.md file is still in the repository.

Author and consume shared Zod input schemas in packages/validators (@repo/validators). Use when adding request validation to an api route, sharing a schema between the api and a browser bundle, or adding a new per-feature schema file.

Install

npx vskill@latest install mimukit/saasaloy/saasaloy-validators

SKILL.md

The same SKILL.md was published earlier as mimukit/saasaloy/saasaloy-validators.

saasaloy-validators

packages/validators holds the project's shared input schemas. Zod is its only runtime dependency. The api validates requests against these schemas, and browser bundles import the same files, so one schema serves both sides.

Where a schema lives

One file per feature, directly under src/. A file named src/waitlist.ts is imported as @repo/validators/waitlist, because the package exports "./*": "./src/*.ts". Do not add index barrels and do not nest feature files in folders.

src/common.ts holds the primitives every feature reuses: errorSchema (the { error: { code, message } } envelope), errorBody, email, id, and pagination. Put a schema there only when two or more features need it. src/phone.ts holds bangladeshMobile; see Bangladeshi mobile numbers.

Using a schema in an api route

An api route validates with zValidator from apps/api/src/contract.ts (imported as ../contract), which is @hono/zod-validator's with the same signature and also records the schema for the agent surfaces. It reads the parsed value with c.req.valid("json"), naming the same target zValidator was given. That call carries the schema's inferred type into the handler. Pass a hook as the third argument so the failure reply uses the shared envelope instead of Hono's default body.

ts
// apps/api/src/routes/signup.ts
import { errorBody } from "@repo/validators/common";
import { signupInput } from "@repo/validators/signup";
import { Hono } from "hono";
import { declare, zValidator } from "../contract";
export const signup = new Hono().post(
"/",
declare({
name: "signup_create",
description: "Sign a person up for the beta.",
agent: { callable: false, reason: "A public form for people, not agents." },
}),
zValidator("json", signupInput, (result, c) => {
if (!result.success) {
const issue = result.error.issues[0];
const message = issue ? `${issue.path.join(".")}: ${issue.message}` : "invalid request body";
return c.json(errorBody("invalid_input", message), 400);
}
}),
(c) => {
const input = c.req.valid("json"); // typed as SignupInput
return c.json({ email: input.email, name: input.name }, 201);
},
);

One named export, one chained expression. Split the .post() into its own signup.post(...) statement and the exported type forgets the route, which empties it out of AppType. The name has to be an export const: the generated apps/api/src/routes.generated.ts imports it by name, as import { signup } from "./routes/signup". Every route also carries one declare({...}) link, its agent statement, and a callable route names its output schema there; keep that schema in this package next to the input one. See the saasaloy-api skill for the full route contract.

result.error.issues[0] is possibly undefined under the template's tsconfig, so guard it rather than indexing straight into .message.

Error responses

Every api error body is the errorSchema envelope, { error: { code, message } }. Build it with errorBody(code, message) from @repo/validators/common; do not hand-write the object and do not return a bare { message }. code is a stable machine-readable string a client can branch on, such as invalid_input or not_found. message is for a human reader and may change.

Bangladeshi mobile numbers

src/phone.ts exports bangladeshMobile and its inferred type BangladeshMobile, imported as @repo/validators/phone. It lives in its own file rather than common.ts because a single-country schema is not a primitive every feature reuses.

ts
import { bangladeshMobile } from "@repo/validators/phone";
import { z } from "zod";
export const signupInput = z.object({
name: z.string().min(1),
mobile: bangladeshMobile, // or bangladeshMobile.optional()
});

It normalizes. The output is canonical E.164, +8801XXXXXXXXX, so a handler never sees the form the user typed. Five input forms are accepted, each after the separators are removed:

InputOutput
01712345678+8801712345678
+8801712345678+8801712345678
8801712345678+8801712345678
1712345678+8801712345678
008801712345678+8801712345678

Four rules decide the rest:

  • Allowed characters are ASCII digits, a space, `-`, `(`, `)`, `.` and a leading `+`. Any other character rejects the input, a tab or a non-breaking space included. The set is a rejection boundary, not a strip list, so hello01712345678world fails instead of reducing to a valid number.
  • ASCII digits only. Bengali numerals (০–৯) are rejected. A Bengali-keyboard user retypes in ASCII digits.
  • The operator check is structural. The digit after the leading 1 must be 3–9, which rejects the 10, 11 and 12 blocks with no operator table to maintain.
  • One failure message for every rejection class: must be a Bangladeshi mobile number, for example +8801712345678.

There is no phone({ country }) option and no optional variant. Write bangladeshMobile.optional(), the way email is used.

This schema and the sms capability check the same country at different layers, which is not duplication. The khudebarta provider checks /^\+880\d{10}$/ on a recipient that is already E.164, and it stays dependency-free because packages/sms takes no runtime dependency (ADR 0020). This schema guards whatever a person typed at the api request boundary, and every value it returns satisfies the provider's regex. See the saasaloy-sms skill for the provider side.

Removal

Remove the dependents first. waitlist, feature-flags, file-uploads and payment-manual depend on validators, so remove validators refuses while any of them is installed. --force overrides the refusal, and it leaves the dependents broken.

saasaloy remove validators deletes the packages/validators workspace (common.ts, phone.ts). It has no reversible patch. The same run takes the @repo/validators line out of apps/api/package.json, because the render without the module has no such line. Run pnpm install afterwards. A file you edited by hand since add stays on disk, untracked, with one line in the report. A schema file you added to the workspace is untracked, so remove leaves it.

Every route that imports @repo/validators stops compiling. Move the schemas you still need next to their routes first.

Failure modes

  • Cannot find module '@repo/validators' in apps/api. The workspace is not installed, or pnpm install has not run since add. Run pnpm install.
  • A route returns 400 for a valid Bangladeshi number. The input uses a form that phone.ts does not normalize. Read "Bangladeshi mobile numbers" above for the accepted forms.

Rules

  • Export the schema and its inferred type together: export const createInput = z.object({...}) and export type CreateInput = z.infer<typeof createInput>.
  • Keep every schema isomorphic. No Workers types, no Node APIs, no process.env, no imports from @repo/db or @repo/api. The file must run unchanged in a browser bundle.
  • Validate input only. Database column shapes belong in packages/db.
  • Return errors through errorSchema so every response carries the same envelope.

Next

Run saasaloy-api to validate a request body in a route with the schema.

Security

  • Security scanPassed, 95 of 100Pattern checks on the skill's files.
  • Model reviewPassed

Quality evaluation

  • Task evaluationNot runNo evaluation yet. Run one in Skill Studio.

Source

Popularity

7-day trend score
0

Not refreshed yet.

Works with

Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.

  • Claude Code
  • Cursor
  • GitHub Copilot
  • Windsurf
  • Codex
  • Gemini CLI
  • Cline
  • Amp
  • Roo Code
  • Goose
  • Continue
  • Kilo Code
  • Junie
  • Trae
  • OpenHands
  • Qwen Code
  • AI Agent
  • Tabnine Chat
  • Sourcegraph Cody
  • Amazon Q
  • Firebase Genkit
  • Sweep
  • Devin
  • Phind
  • Mentat
  • Claude Desktop
  • Aider
  • GPT Pilot
  • Plandex
  • bolt.new
  • v0
  • Replit Agent
  • Anse
  • TypingMind
  • BetterChatGPT
  • LibreChat
  • Warp AI
  • Pieces
  • Fig AI
Embed badge
vskill VERIFIED badge
[![vskill VERIFIED](https://verified-skill.com/api/v1/skills/mimukit/saasaloy/saasaloy-validators/badge)](https://verified-skill.com/skills/mimukit/saasaloy/saasaloy-validators)

Something wrong with this skill or its page? Tell us.