VineJS
The AdonisJS target writes its own VineJS validators from your contract when you link none. AdonisJS validates with VineJS already, and the server names each issue by the contract rule.
Used by: AdonisJS only, when its entry has no validators link.
Set up
Section titled “Set up”Nothing to add: the AdonisJS starter depends on @vinejs/vine, and the @seampact/codegen-adonis target writes the validators in its own validators/ folder. There is no separate validators target.
To use zod or yup instead, add a validators entry and link it (Switch the validator).
What you get
Section titled “What you get”The files have the same layout as the zod ones: schemas/input.ts, schemas/output.ts, operations/input.ts and wire-checks.ts, plus a vine-support.ts.
A generated schema is not a chain of vine.object() calls. It is a plan: a plain object that lists each field, its type and its checks (a rule name, its limit and its message). vine-support.ts reads the plan and builds the VineJS validator. So you read the contract to know what is checked, and you do not edit the plan.
For CreateTask, the plan says:
titleis a required string with a minimum length of 1 and a maximum length of 200.effortis an optional integer with a minimum of 0.- Any other key is refused.
An operation validator checks path, query, headers and body together.
When a check fails
Section titled “When a check fails”Each VineJS error becomes one issue of the 400 body, named by the contract rule.
Native or consistent rules
Section titled “Native or consistent rules”@seampact/codegen-adonis takes the rules option (native by default). With native, the validators use VineJS’s own rules, which differ from the contract in a few places.
- Lengths count UTF-16 units: an emoji counts 2, so
maxLength: 1refuses “😀”. uuidalso checks the version and variant digits.00000000-0000-9000-8000-000000000000is refused.date-time,exclusiveMinimum,exclusiveMaximumandmultipleOfhave no VineJS rule: they stay the contract’s checks.- Under the native rules, an issue’s message may be VineJS’s own text; the rule name is the same in both modes.
Set rules: seampact-consistent on the server entry for the contract’s exact checks (AdonisJS options).
Limits
Section titled “Limits”The generator refuses by name a oneOf, a property default, a nullable value other than an opaque one and the other forms in Generate fails.
- AdonisJS.
- The 400 body: When a check fails.