Skip to content

Update dependency @vinejs/vine to v4#534

Open
renovate[bot] wants to merge 1 commit intomainfrom
renovate/vinejs-vine-4.x
Open

Update dependency @vinejs/vine to v4#534
renovate[bot] wants to merge 1 commit intomainfrom
renovate/vinejs-vine-4.x

Conversation

@renovate
Copy link
Contributor

@renovate renovate bot commented Oct 17, 2025

This PR contains the following updates:

Package Change Age Adoption Passing Confidence
@vinejs/vine ^1.8.0^4.0.0 age adoption passing confidence

Release Notes

vinejs/vine (@​vinejs/vine)

v4.2.0: Partial objects, shorthand for creating object validators, new vat rule, and global transforms

Compare Source

4.2.0 (2025-12-11)

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
Features
Reverts

What's Changed

New Contributors

Full Changelog: vinejs/vine@v4.1.0...v4.2.0

v4.1.0: Accept confirmation field alias via "as" property

Compare Source

Features
  • accept confirmation field alias via "as" property (cacc3ca)

Full Changelog: vinejs/vine@v4.0.1...v4.1.0

v4.0.1: Fix date rule to work when the field has been marked as optional

Compare Source

Bug Fixes

What's Changed

Full Changelog: vinejs/vine@v4.0.0...v4.0.1

v4.0.0: Bug fixes, support for standard schema, file validation, optional and nullable unions

Compare Source

Breaking changes

Removed BaseModifiers class

This release refactors parts of VineJS internals and removes the BaseModifiers class.
In most cases, this change will not affect your application. However, if you were extending or directly using BaseModifiers for a custom use case, you may need to adjust your implementation.
If you run into any issues, please open an issue on GitHub.


Report confirmed rule errors on the confirmation field

The confirmed rule is commonly used for fields like password to ensure a matching field (for example, password_confirmation) has the same value.
Previously, when the values didn’t match, the validation error was reported on the original field (e.g. password).

This created a poor user experience — you would see an error message like

“The values of password and password_confirmation must be the same”
next to the password field, even though the issue was with the confirmation field.

This behavior has now been corrected.
Errors from the confirmed rule are now reported on the confirmation field (e.g. password_confirmation).
Since this changes the location of validation errors, it is considered a breaking change.


Introducing dataTypeValidator

We identified a bug in how Vine handled validations when bail(false) was used.
When bail mode is disabled, all validations on a field should run — even if earlier ones fail.

For example:

const schema = vine.object({
  email: vine.string().email().minLength(5).bail(false)
})

const data = { email: 'virk' }

In this case, both email() and minLength() validations should report errors.
However, Vine stopped after the first failure because of an internal field.isValid check.
We removed this check to ensure all validations run as expected.

This change, however, introduced redundant type checks — for instance, if a field wasn’t a string, each subsequent rule (email(), minLength(), etc.) had to recheck the type manually.

To solve this, we introduced dataTypeValidator.

The dataTypeValidator is a special validator defined at the schema level (e.g. string, number, etc.).
When it fails, the compiler automatically skips all subsequent validations for that field, preventing redundant checks and improving performance.

If you’ve defined custom Schema classes:

  • Define a dataTypeValidator for each of them.
  • The validator must return true or false and report errors using the errorReporter when the check fails.

Notable improvements

Added support for the Standard Schema specification

Vine validators now implement the Standard Schema specification.
This means Vine schemas can now integrate directly with tools and frameworks that support the standard — such as Hono.

Example:

import vine from '@​vinejs/vine'
import { sValidator } from '@​hono/standard-validator'

const validator = vine.compile(
  vine.object({
    name: vine.string(),
    age: vine.number(),
  })
)

app.post('/', sValidator('json', validator), (c) => {
  const data = c.req.valid('json')
  return data
})

unionOfTypes now supports literal, optional, and nullable

The unionOfTypes schema type now supports the optional() and nullable() modifiers.
You can also use the literal() schema type within a union, allowing for more expressive and flexible validation rules.

[!NOTE]
The union() schema type also supports optional() and nullable() modifiers.

Example:

const schema = vine.object({
  ipRange: vine
    .unionOfTypes([
      vine.string(),
      vine.array(vine.string()),
      vine.literal('*'),
    ])
    .optional()
})

Here, the ipRange field can be:

  • A string
  • An array of strings
  • The literal value '*'
  • Or completely omitted

Pick and omit properties from existing schemas

You can now compose new schemas from existing ones by picking or omitting specific properties.
This makes it easy to reuse and adapt schemas across different contexts without duplicating field definitions.

Use object.pick() to select specific properties, or object.omit() to exclude them.

Example:

const createUserSchema = vine.object({
  fullName: vine.string(),
  email: vine.string().email(),
  password: vine.string().minLength(8),
})

// Reuse part of the schema for login
const loginSchema = vine.object({
  ...createUserSchema.pick(['email', 'password']),
})

This keeps your schemas consistent, maintainable, and DRY.

Commits

Bug Fixes
Code Refactoring
Features
  • add nonNegative and nonPositive number rules (bbd01bf)
  • rename vine.file to vine.nativeFile (df98e47)
  • add File schema that returns a platform native File instance (6842fdb)
  • add optional and nullable modifiers to unionOfTypes (95a5f7e), closes #​75
  • add support for picking and omitting properties (6086716), closes #​80
  • add support for standard schema spec (768beed), closes #​93
  • allow vine.union to be optional or nullable (96aba9b), closes #​75
  • introduce vine.optional and vine.null schema types (6d3c12e), closes #​75
  • report confirmed error on the confirmation field and rename confirmationField to as (51ed080)
BREAKING CHANGES
  • The error for the confirmed rule is no longer reported on the same field. Instead it is reported on the _confirmation field
  • The BaseModifiers class does not exist anymore, hence cannot be exported
  • The value zero will fail validation for both positive and negative validation rules, since zero is a neutral number. If you want the old behavior, replace positive rule with nonNegative and negative rule with nonPositive.

v3.0.1: Fix CamelCase utilities not work with keys containing numbers

Compare Source

Bug Fixes
  • CamelCase utility to work with existing camelCase values with numbers (9012036), closes #​94

Full Changelog: vinejs/vine@v3.0.0...v3.0.1

v3.0.0: Breaking changes and bug fixes

Compare Source

This release contains a few breaking changes along with a handful of new improvements and bug fixes.

Breaking changes
Infer type

The infer type of schema now marks optional fields as optional within the TypeScript types. This ensures the property can be missing altogether from the data object/inferred types vs being marked as undefined explicitly. For example:

// Schema
vine.object({
    username: vine.string(),
    age: vine.number().optional(),
})

// Old output
{
    age: number | undefined;
    username: string;
}

// New output
{
    age?: number | undefined;
    username: string;
}
SUBTYPE symbol

Custom types extending the VineJS BaseLiteralType now must define the symbols.SUBTYPE property on the schema. This property can be used by schema transformers to get a more accurate type for the schema node. Here's how the StringSchema defines the SUBTYPE property.

For example:

import { symbols, BaseLiteralType } from '@​vinejs/vine'

class MySchemaType extends BaseLiteralType<Input, Output, CamelCaseOutput> {
   [symbols.SUBTYPE] = 'multipartFile'
}
Bug Fixes
Features
  • add subtype property to schema output (818fbf0), closes #​64
  • add support for conditional validation in arrays, object, records and tuples (890228e), closes #​71
  • add support for parsing iso8601 dates (fe61951), closes #​65
  • add support for ULID validation (#​58) (02d3a28)
Pull Requests
New Contributors

Full Changelog: vinejs/vine@v2.1.0...v3.0.0

v2.1.0: Add "tryValidate", "toJSON" method and "in" validation rule

Compare Source

tryValidate

The tryValidate method can be used to perform validation without throwing a validation error. Instead, the errors are returned as the return value of the method, which is a tuple.

const [error, result] = validator.tryValidate({ data: {} })

The try prefix is inspired from the Java world.

in

The in validation rule has been added for the VineNumber schema type and can be used to ensure the value of field is part of the allowed values list.

toJSON

The validator.toJSON method can be used to get the validator and its refs as JSON.

Commits

  • feat: add tryValidate method to Vine (a70ff38)
  • feat: add tryValidate method (cebb8e0)
  • fix: add "in" rule in default number rules (#​54) (39204e4)
  • chore: migrate to release-it (0b5e212)
  • feat: add in rule for number (#​53) (72912af)
  • feat: export modifiers (#​48) (34e07fc)
  • chore: update dependencies (a7e18b7)
  • style: reformat codebase (62d450c)
  • feat: add validator.toJSON method to get compiled schema and refs (5259933)

What's Changed

New Contributors

Full Changelog: vinejs/vine@v2.0.0...v2.1.0

v2.0.0: Improved error reporting for fields inside arrays and infer schema input types

Compare Source

This release contains a couple of minor breaking changes. So let's first talk about them.

Improved error reporting for fields inside arrays ( Breaking )

In the previous versions of VineJS, the error reporting for fields inside arrays could have been better.

Given the following schema and data

const schema = vine.object({
  categories: vine.array(vine.number()),
})

const data = {
  categories: [1, 'foo', 'bar', 11],
}

The errors reported up until 2.0 were

{
  field: 'categories.*',
  index: 1,
  message: 'The 1 field must be a number',
  rule: 'number',
},
{
  field: 'categories.*',
  index: 2,
  message: 'The 2 field must be a number',
  rule: 'number',
}

If you notice, the field name inside arrays is defined as categories.* and not the actual index of the item inside the array. Now, you may think that I can replace the * with the index property value and get a nested path to the item index within the array.

Well, the replacement of * might work in this situation. But it will not work when there are errors inside nested arrays or the field that failed the validation is a grandchild of an array. Because the index property only exists when the field is an immediate child of an array.

But anyway, after this release, you do not have to perform any manual substitutions. The field names are nested paths with the correct index. The following is an example of errors with @vinejs/vine@2.

{
  field: 'categories.1',
  index: 1,
  message: 'The 1 field must be a number',
  rule: 'number',
},
{
  field: 'categories.2',
  index: 2,
  message: 'The 2 field must be a number',
  rule: 'number',
}

Infer Schema Input value ( Breaking )

After this release, you can infer the input values a Schema type accepts. Let's consider the following example.

import { InferInput } from '@&#8203;vinejs/vine/types'

const schema = vine.object({
  is_admin: vine.boolean()
})

InferInput<typeof Schema>
{
  is_admin: boolean | string | number
}

If you notice, the is_admin property accepts a boolean | string | number. VineJS is built for parsing form inputs submitted over HTTP. Therefore, it receives all inputs as string values and performs normalization before performing any sort of validation.

Because of this change, the BaseSchema classes accept another generic value for the InputTypes. So, if you use the BaseSchema anywhere in your apps, make sure to pass the Input type as the first generic argument.

Also, please consult this commit for a better understanding of the change. df27df8

Define error messages for specific array index or a wildcard ( New feature )

Now, you will be able to define custom error messages for specific array indexes with a wildcard fallback for rest of the indexes. For example:

{
  "contacts.0.email.required": "The primary email address is required",
  "contacts.*.email.required": "The email address is required",
}

Commits

  • style: remove unused type 9dd733c
  • feat: add support for inferring schema input types df27df8
  • feat: improve error reporting for fields inside arrays 3d59dad
  • chore: update dependencies 8ff246f

What's Changed

New Contributors

Full Changelog: vinejs/vine@v1.7.0...v2.0.0


Configuration

📅 Schedule: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.

Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 Ignore: Close this PR and you won't be reminded about this update again.


  • If you want to rebase/retry this PR, check this box

This PR was generated by Mend Renovate. View the repository job log.

@renovate renovate bot force-pushed the renovate/vinejs-vine-4.x branch 2 times, most recently from c6e104c to 94295eb Compare October 27, 2025 10:58
@renovate renovate bot force-pushed the renovate/vinejs-vine-4.x branch 2 times, most recently from 4716fce to 2fc23cd Compare November 3, 2025 06:51
@renovate renovate bot force-pushed the renovate/vinejs-vine-4.x branch from 2fc23cd to 4ef4360 Compare November 10, 2025 16:38
@renovate renovate bot force-pushed the renovate/vinejs-vine-4.x branch from 4ef4360 to 1617429 Compare November 18, 2025 18:51
@renovate renovate bot force-pushed the renovate/vinejs-vine-4.x branch from 1617429 to cd9c3ab Compare December 3, 2025 17:07
@renovate renovate bot force-pushed the renovate/vinejs-vine-4.x branch from cd9c3ab to fe6c9c0 Compare December 11, 2025 10:05
@renovate renovate bot force-pushed the renovate/vinejs-vine-4.x branch from fe6c9c0 to 2921a41 Compare December 23, 2025 20:03
@renovate renovate bot force-pushed the renovate/vinejs-vine-4.x branch from 2921a41 to 4d6e648 Compare December 31, 2025 14:32
@renovate renovate bot force-pushed the renovate/vinejs-vine-4.x branch 2 times, most recently from dc4ede3 to d3638ba Compare January 15, 2026 07:30
@renovate renovate bot force-pushed the renovate/vinejs-vine-4.x branch from d3638ba to 0da36e0 Compare January 19, 2026 17:46
@renovate renovate bot force-pushed the renovate/vinejs-vine-4.x branch 2 times, most recently from 844ae76 to f552fdd Compare February 6, 2026 13:38
@renovate renovate bot force-pushed the renovate/vinejs-vine-4.x branch from f552fdd to aaf83b8 Compare February 12, 2026 15:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants