@vinejs/vine
4.4.0 · 27 Apr 2026MIT595.8k / weekRepositoryHomepagenpmAtom feed
26 stable releases, newest first, by release line. Notes are quoted as the maintainers published them.
- 4.x · latest line
4.4.0
27 Apr 2026Substitue nested field names in custom message
Substitue nested field names in custom message
4.3.1
7 Apr 2026Maintenance only: docs, tests, build or refactoring. Nothing changes in how you use it.
4.3.0
6 Feb 2026Handling of optional properties
Add StandardJSONSchema support
VineJS now supports converting validation schemas to JSON Schema Draft 7 format, enabling interoperability with standard JSON Schema validators and tools.
Converting to JSON Schema
Use the
.toJSONSchema()method to convert any VineJS validator to JSON Schema:import vine from '@vinejs/vine' const validator = vine.create({ name: vine.string(), email: vine.string().email(), age: vine.number().min(18), }) const jsonSchema = validator.toJSONSchema() console.log(jsonSchema)Output:
{ "type": "object", "properties": { "name": { "type": "string" }, "email": { "type": "string", "format": "email" }, "age": { "type": "number", "minimum": 18 } }, "required": ["name", "email", "age"], "additionalProperties": false }Using with Standard Validators
The generated JSON Schema works seamlessly with validators like AJV:
import { Ajv } from 'ajv' import addFormats from 'ajv-formats' import vine from '@vinejs/vine' const ajv = new Ajv() addFormats.default(ajv) const validator = vine.create({ username: vine.string().minLength(3), email: vine.string().email(), role: vine.enum(['admin', 'user', 'guest']), }) const validate = ajv.compile(validator.toJSONSchema()) // Validate data const isValid = validate({ username: 'johndoe', email: 'john@example.com', role: 'admin', }) if (!isValid) { console.log(validate.errors) }StandardSchema Compliance
VineJS validators now implement the StandardJSONSchemaV1 specification, enabling seamless integration with the broader JavaScript validation ecosystem.
const validator = vine.create({ name: vine.string(), }) // Access via standard interface const schema = validator['~standard'].jsonSchema.input({ target: 'draft-2020-12' })Bug Fixes
Handle use-case when convertEmptyStringsToNull flag is applied on a string with multiple empty spaces (5a99348), closes #138
Handling of optional properties
Features
Add StandardJSONSchema support
Implement json-schema support
What's Changed
Add json-schema support
Add StandardJSONSchema support
4.2.0
11 Dec 2025Allow vine.nativeFile to work with vine.unionOfTypes b34f1b0
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 usevine.compile(vine.object({})), justvine.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 namedtoOptional) 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
Features
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
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
vatrulerules: Add
strongPasswordruleRevert "feat(rules): add
strongPasswordrule"
4.1.0
27 Oct 2025Accept confirmation field alias via "as" property
4.0.1
21 Oct 2025Optional date
Optional date
4.0.0
17 Oct 2025- breaking
Define a
dataTypeValidatorfor each of them. - breaking
The validator must return
trueorfalseand report errors using theerrorReporterwhen the check fails. - breaking
The error for the confirmed rule is no longer reported on the same field. Instead it is reported on the
_confirmationfield
Breaking changes
Removed
BaseModifiersclassThis release refactors parts of VineJS internals and removes the
BaseModifiersclass.
In most cases, this change will not affect your application. However, if you were extending or directly usingBaseModifiersfor a custom use case, you may need to adjust your implementation.
If you run into any issues, please open an issue on GitHub.Report
confirmedrule errors on the confirmation fieldThe
confirmedrule is commonly used for fields likepasswordto 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 thepasswordfield, even though the issue was with the confirmation field.This behavior has now been corrected.
Errors from theconfirmedrule 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
dataTypeValidatorWe identified a bug in how Vine handled validations when
bail(false)was used.
Whenbailmode 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()andminLength()validations should report errors.
However, Vine stopped after the first failure because of an internalfield.isValidcheck.
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
dataTypeValidatoris 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:
- breaking
Define a
dataTypeValidatorfor each of them. - breaking
The validator must return
trueorfalseand report errors using theerrorReporterwhen 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 })unionOfTypesnow supportsliteral,optional, andnullableThe
unionOfTypesschema type now supports theoptional()andnullable()modifiers.
You can also use theliteral()schema type within a union, allowing for more expressive and flexible validation rules.Note
The
union()schema type also supportsoptional()andnullable()modifiers.Example:
const schema = vine.object({ ipRange: vine .unionOfTypes([ vine.string(), vine.array(vine.string()), vine.literal('*'), ]) .optional() })Here, the
ipRangefield 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, orobject.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
Fail positive and negative validations when value is a neutral number (9136e4f), closes #97 #117
Update logic of converting string values to DayJS instances (2e74503), closes #102 #123
Move date internal properties to the fieldContext and not the meta
Features
Add nonNegative and nonPositive number rules
Rename vine.file to vine.nativeFile
Add File schema that returns a platform native File instance
Add optional and nullable modifiers to unionOfTypes (95a5f7e), closes #75
Add support for picking and omitting properties (6086716), closes #80
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
Breaking changes
- breaking
The error for the confirmed rule is no longer reported on the same field. Instead it is reported on the
_confirmationfield - breaking
The
BaseModifiersclass does not exist anymore, hence cannot be exported - breaking
The value zero will fail validation for both
positiveandnegativevalidation rules, since zero is a neutral number. If you want the old behavior, replacepositiverule withnonNegativeandnegativerule withnonPositive.
- 3.x
3.0.1
13 Mar 2025Reading the note…
3.0.0
1 Dec 2024Reading the note…
- 2.x
2.1.0
2 Jun 2024Reading the note…
2.0.0
29 Mar 2024Reading the note…
- 1.x
1.8.0
13 Mar 2024Reading the note…
1.7.1
29 Jan 2024Reading the note…
1.7.0
22 Nov 2023Reading the note…
1.6.0
28 Jul 2023Reading the note…
1.5.3
25 Jul 2023Reading the note…
1.5.2
19 Jul 2023Reading the note…
1.5.1
11 Jul 2023Reading the note…
1.5.0
10 Jul 2023Reading the note…
1.4.1
16 Jun 2023Reading the note…
1.4.0
15 Jun 2023Reading the note…
1.3.0
14 Jun 2023Reading the note…
1.2.0
13 Jun 2023Reading the note…
1.1.1
12 Jun 2023Reading the note…
1.1.0
12 Jun 2023Reading the note…
1.0.0
10 Jun 2023Reading the note…