Skip to content

Conversation

@ssalbdivad
Copy link
Member

JSON Schema improvements

  • Adds support for the new Standard JSON Schema interface (see standardschema.dev)
  • Now accepts a target option and can generate draft-07 in addition to draft-2020-12

Standard Schema is now a valid definition

Any Standard Schema compliant validator can now be passed directly to type, either directly or nested in a structural ArkType definition, and will be fully inferred and validated.

import { type } from "arktype"
import * as v from "valibot"
import z from "zod"

const ZodAddress = z.object({
	street: z.string(),
	city: z.string()
})

const User = type({
	name: "string",
	age: v.number(),
	address: ZodAddress
})

e(x)ec mode for regex types

const User = type({
	// x-prefix a regex literal to parse its type-safe capture groups
	birthday: "x/^(?<month>\\d{2})-(?<day>\\d{2})-(?<year>\\d{4})$/"
})

const data = User.assert({ birthday: "05-21-1993" })

// fully type-safe via arkregex
console.log(data.birthday.groups) // { month: "05", day: "21", year: "1993" }

more flexible type.declare

Optionality can now be expressed via a property value in addition to its key:

type Expected = { f?: string }

const T = type.declare<Expected>().type({
	// previously failed with `"f?" is missing`
	f: "string?"
})

fixed a bug causing predicate errors after the first to not be reported

import { type } from "arktype"

const Dates = type({
	date1: "string.date",
	date2: "string.date",
	date3: "string.date"
})

// now correctly reports the errors on `date2` and `date3` in addition to `date1`
Dates.assert({
	date1: "",
	date2: "",
	date3: ""
})

See #1557

@github-project-automation github-project-automation bot moved this to To do in arktypeio Dec 3, 2025
@ssalbdivad ssalbdivad merged commit 9c4045b into main Dec 3, 2025
6 checks passed
@ssalbdivad ssalbdivad deleted the pre-2.2 branch December 3, 2025 06:28
@github-project-automation github-project-automation bot moved this from To do to Done (merged or closed) in arktypeio Dec 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done (merged or closed)

Development

Successfully merging this pull request may close these issues.

3 participants