axiosleo/node-koapp/koapp-model
Claude Code and agent skill by axiosleo/node-koapp
- community
Checking that the SKILL.md file is still in the repository.
Validate and serialize structured data with the @axiosleo/koapp Model class powered by validatorjs. Use when creating typed payload objects, running rules like required/integer/email/min/max, converting between JSON and plain objects, listing properties, or automatically raising HttpError(400) on validation failure inside a koapp handler.
Install
npx vskill@latest install axiosleo/node-koapp/koapp-modelSKILL.md
@axiosleo/koapp Model
Source: `src/model.js`.
Model is a lightweight data container around validatorjs. It assigns incoming fields onto itself, optionally validates them, and provides utility methods for serialization.
Import
Constructor
| Arg | Type | Purpose | ||
|---|---|---|---|---|
obj | object | Source data; each key is copied onto the instance via Object.assign | ||
rules | Rules | validatorjs rule set, e.g. `{ name: 'required | string' }` | |
messages | ErrorMessages | Custom error messages keyed by rule, e.g. { required: 'The :attribute is required.' } |
When rules are provided and validation fails, the constructor throws HttpError(400, <first-error-message>). Inside a koapp handler that translates to a standard 400 response without any extra plumbing.
Static helper
Shortcut for new Model(obj, rules, messages) that benefits from subclass context (same as new this(...)).
Instance methods
| Method | Returns | Notes | |
|---|---|---|---|
toJson() | string | JSON.stringify(this) | |
toObj() | object | JSON.parse(this.toJson()); strips class identity | |
properties() | string[] | Enumerable own keys | |
count() | number | properties().length | |
validate(rules, messages?) | Validator | Runs validatorjs manually and returns the raw Validator object |
validate() does not throw - use it when you need the full error map:
Extending Model
When user is created successfully, user.name, user.email, user.age are all available, plus any custom methods.
Validation rules cheat sheet
Common rules from validatorjs:
Combine with |: required|string|min:3|max:64.
Nesting Models
Model instances serialize via JSON, so nesting works naturally:
Note that toObj() returns plain objects - class identity is stripped, so user.toObj().address instanceof Model === false.
Validating without Model
If you only need to validate a payload once without persisting an instance, Model.create(data, rules) and discard the return value:
Comparison with router-level validators
| Router validators | Model validation | |
|---|---|---|
| Declarative, lives next to the route | Imperative, lives in code | |
Fields split into params / query / body | Arbitrary object shape | |
| Runs automatically before the handler | Runs where you call it | |
| Limited to the request payload | Can be reused for DB rows, intermediate data, etc. |
Use router validators for request shape enforcement, and Model when you need to pass the validated data around or serialize it.
Common pitfalls
- Validators that look at missing fields (e.g.
integer) still pass when
the field is absent unless paired with required.
- The 400 message is the first failing rule's message; the others are
discarded. Use model.validate(...) manually if you need all errors.
Object.assign(used in the constructor) copies own enumerable
properties; prototype getters/setters on obj are not preserved.
toObj()andtoJson()include all own properties. If you want to
hide fields, delete them before serialization or implement a custom toJSON().
See also
- Response helpers used after a successful
Model.create: koapp-response - Validating fields declaratively on the route: koapp-router
- Concrete model recipes: examples.md
Security
- Security scanPassed, 100 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingassets/skills/koapp-model/SKILL.md
Popularity
- Repository stars
- 44
- Repository forks
- 11
- Repository npm downloads, 7 days
- 322
- 7-day trend score
- 34
Stars and forks are for the whole GitHub repository, not this skill alone. Downloads are for the repository's npm package. Refreshed 9 Jun 2026, 4 months ago.
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
[](https://verified-skill.com/skills/axiosleo/node-koapp/koapp-model)