Packages

@vinejs/vine

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

Your version

4.3.0

6 Feb 2026Where it was published

4.4.0 is the newest release of 4.x.

In short

3 new2 fixed

Release note

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