Replies: 1 comment
-
|
If the field is meant to accept only a fixed set of string values, use For example: import { defineCollection, z } from "@nuxt/content"
export const collections = {
docs: defineCollection({
type: "page",
source: "docs/**/*.md",
schema: z.object({
kind: z.enum(["value-1", "value-2"]),
}),
}),
}Then frontmatter like this is valid: kind: value-1and anything outside that list should fail validation. If the values are actual numbers, use literals: z.union([z.literal(1), z.literal(2)])
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
How to make the collection field z.num['value-1', value-2'] validate ?
Now i can put any value in frontmatter md and ssg build run without any errors
Beta Was this translation helpful? Give feedback.
All reactions