| name | core |
| description | Helps developers build, explain, or refactor a Vest.js 5.4 validation suite. Use this whenever the user asks for a first Vest example, wants to write a suite from scratch, asks when to use `create` versus `staticSuite`, mentions `test` or `enforce`, or wants idiomatic 5.x suite structure without yet getting into advanced conditional or async behavior. |
Vest.js 5.4 core workflow
Use this skill to produce the default, idiomatic Vest 5.4 setup.
Start from these rules
- Keep the validation suite separate from feature or UI code.
- Use
create(...) for stateful client-side suites that rerun over time.
- Use
staticSuite(...) for stateless or server-style validation where each run should stand alone.
- If selective validation is part of the design, accept a field parameter and call
only(field) unconditionally near the top of the suite.
- Use
test(fieldName, message, body) for human-readable validations.
- Use
enforce(...) for clear assertions instead of hand-rolled boolean pyramids.
- Prefer
result.isTested(field) over custom touched or dirty flags when the question is โhas this field been validated yet?โ
Recommended workflow
- Define the data shape first.
- Choose
create or staticSuite based on whether state should persist between runs.
- Add
only(field) if the suite will validate interactively one field at a time.
- Add
test(...) blocks with stable field names and clear messages.
- Return the suite and use the result object or
suite.get() to inspect state.
Canonical patterns
Stateful UI suite
Use create(...) when the same suite instance will rerun as the user edits data.
Stateless validation
Use staticSuite(...) for request validation, scripts, or isolated invocations where prior state should not affect the next run.
Selective validation
If the suite accepts a current field, use:
only(field) for focused validation during interaction
- no extra branching around the
only() call itself
That keeps execution order stable across runs.
Pitfalls to correct immediately
- putting validation logic inline in the UI instead of in a suite
- using
create(...) when a stateless staticSuite(...) is the better fit
- wrapping
only(field) in if (field)
- inventing duplicate form-state tracking when
isTested() or hasErrors() already answers the question
- using vague messages that make result handling harder
Output style
When answering the user:
- give a complete, minimal suite rather than disconnected one-liners
- explain why the suite is stateful or stateless
- keep field names, messages, and result access aligned with the example
Quick decision hints
- โValidate as the user typesโ usually means
create(...) plus only(field).
- โValidate this payload on submit/server-sideโ usually means
staticSuite(...).
- โHow do I start with Vest?โ should trigger this skill first.
References to consult when needed
../../../instructions/vest.instructions.md
https://vestjs.dev/docs/5.x/get_started
https://vestjs.dev/docs/5.x/concepts
https://vestjs.dev/docs/5.x/api_reference