Packages

@vinejs/vine

4.4.0 · 27 Apr 2026MIT595.8k / weekRepositoryHomepagenpmAtom feed

Your version

4.2.0

11 Dec 2025Where it was published

4.4.0 is the newest release of 4.x.

In short

11 new3 fixed2 changed

Release note

Shorthand method to create object validators

Introduced vine.create() method to create validators directly from top-level objects (7960e28). As a result of this, you do not have to use vine.compile(vine.object({})), just vine.create({}) will give the same result.

  import vine from '@vinejs/vine'

  // Create a validator from a plain object schema
-  const validator = vine.compile(
-    vine.object({
-      username: vine.string().minLength(3),
-      password: vine.string().minLength(8),
-      terms: vine.boolean().isTrue()
-    })
-  )
+  const validator = vine.create({
+    username: vine.string().minLength(3),
+    password: vine.string().minLength(8),
+    terms: vine.boolean().isTrue()
+  })

  // Use the validator
  const data = await validator.validate({
    username: 'johndoe',
    password: 'secret123',
    terms: true
  })

Object Schema Enhancement

Added partial() method (initially named toOptional) to make all properties of an object schema optional (#127, 08a3472)

  import vine from '@vinejs/vine'

  // Define a base schema
  const createUserValidator = vine.create({
    name: vine.string(),
    email: vine.string().email(),
    age: vine.number()
  })

  // Make all properties optional
  const updateUserValidator = vine.create(
    createUserValidator.schema.partial()
  )

  // Now all fields are optional - useful for updates/patches
  const result = await updateUserValidator.validate({
    { email: 'user@example.com' }
  })

Global Transforms

Added support for global transforms to transform date objects globally across all validators (f368feb). This will allow AdonisJS projects to always return a Luxon DateTime object when validating dates.

  import { DateTime } from 'luxon'
  import { VineDate } from '@vinejs/vine'

  declare module '@vinejs/vine/types' {
    interface VineGlobalTransforms {
      date: DateTime
    }
  }

  VineDate.transform((value) => {
    return new DateTime.fromJSDate(value)
  })

  vine.create({
    birthDate: vine.date(), // instanceof DateTime
    createdAt: vine.date() // instanceof DateTime
  })

Bug Fixes

  • Allow vine.nativeFile to work with vine.unionOfTypes b34f1b0

  • Object toOptional types (#130) d28c949, closes #130

Features

  • Add toOptional to object (#127) 08a3472, closes #127

  • Add vine.create method to create validators from top-level objects 7960e28

  • Introduce global transforms to transform the date objects globally f368feb

  • Make validator schema public to allow cloning it 752acff

  • Rename toOptional to partial b6e3461

  • rules: add strongPassword rule (#132) b443638, closes #132

  • rules: add vat rule (#131) 999b667, closes #131

  • Update types and write types benchmarks 2fea19c

Reverts

What's Changed

  • Revise nativeFile method example in documentation

  • Add toOptional to object

  • Object toOptional types

  • rules: Add vat rule

  • rules: Add strongPassword rule

  • Revert "feat(rules): add strongPassword rule"