No Runtime Errors
Catch content validation issues at build time, not in production. Your users will never see broken content again.
Framework-agnostic validation for Markdown and Standard Schema — built for Astro, Next.js, and modern frameworks.
import { loadUserSchema, validateWithSchema } from '@watthem/fieldtest';
import type { StandardSchemaV1 } from '@watthem/fieldtest';
// Define your schema
const blogSchema: StandardSchemaV1 = {
version: '1',
name: 'blog-post',
fields: {
title: { type: 'string', required: true },
author: { type: 'string', required: true },
published: { type: 'boolean', required: true },
tags: { type: 'string', array: true }
}
};
// Validate your content
const schema = loadUserSchema(blogSchema);
const markdown = `---
title: "Getting Started with FieldTest"
author: "Jane Developer"
published: true
tags: ["typescript", "validation", "markdown"]
---
# Getting Started
This post shows how easy it is to validate content with FieldTest!
`;
const result = validateWithSchema(markdown, schema);
if (result.valid) {
console.log('✓ Content validated successfully!');
} else {
result.errors.forEach(error => {
console.error(`❌ ${error.field}: ${error.message}`);
});
}
// src/content/config.ts
import { defineCollection } from 'astro:content';
import { loadUserSchema } from '@watthem/fieldtest';
const blog = defineCollection({
type: 'content',
schema: (z) => z.object({
title: z.string(),
author: z.string()
}).refine(data => {
const result = validateWithSchema(
generateMarkdown(data),
loadUserSchema(blogSchema)
);
return result.valid;
})
});
// Validate in generateStaticParams or getStaticProps
export async function generateStaticParams() {
const schema = loadUserSchema(blogSchema);
const posts = fs.readdirSync('./content');
return posts.map(post => {
const content = fs.readFileSync(`./content/${post}`, 'utf-8');
const result = validateWithSchema(content, schema);
if (!result.valid) {
throw new Error(`Invalid post: ${result.errors.map(e => e.message)}`);
}
return { slug: post.replace('.md', '') };
});
}
// Universal validation that works anywhere
import { validateWithSchema } from '@watthem/fieldtest';
const isValid = validateWithSchema(content, schema).valid;
Stop wrestling with framework-specific validation. FieldTest works the same way across Astro, Next.js, Remix, SvelteKit, and more.
Based on the emerging Standard Schema specification, ensuring your validation logic is future-proof and interoperable.
Designed to handle large content sites. Validates thousands of documents in seconds with minimal memory usage.
Comprehensive TypeScript support, clear error messages, extensive documentation, and helpful tooling integrations.
Get up and running in less than 5 minutes with our comprehensive getting started guide.
Get Started →Explore real-world examples and patterns for different frameworks and use cases.
Browse Examples →Comprehensive documentation of all functions, types, and configuration options.
View API →