Skip to content

FieldTestValidation toolkit for content

Framework-agnostic validation for Markdown and Standard Schema — built for Astro, Next.js, and modern frameworks.

FieldTest - Framework-agnostic validation toolkit

Quick Example

typescript
import { parseMarkdown, validateWithSchema, z } from '@fieldtest/core';

// Define your schema using Zod (Standard Schema compliant)
const blogSchema = z.object({
  title: z.string(),
  author: z.string(),
  published: z.boolean(),
  tags: z.array(z.string()).optional()
});

// Parse your markdown content
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 doc = parseMarkdown(markdown);

// Validate the frontmatter against your schema
const result = await validateWithSchema(blogSchema, doc.frontmatter);

if ('issues' in result) {
  result.issues.forEach(issue => {
    console.error(`❌ ${issue.path?.join('.')}: ${issue.message}`);
  });
} else {
  console.log('✓ Content validated successfully!');
  console.log('Title:', result.title);  // Type-safe access
}

Framework Integration

Astro

typescript
// src/content/config.ts
import { defineCollection } from 'astro:content';
import { z } from '@fieldtest/core';

// Astro's built-in Zod works with FieldTest schemas
const blog = defineCollection({
  type: 'content',
  schema: z.object({
    title: z.string(),
    author: z.string(),
    published: z.boolean().default(false),
    tags: z.array(z.string()).optional()
  })
});

export const collections = { blog };

Next.js

typescript
// Validate content at build time
import { parseMarkdown, validateWithSchema, z } from '@fieldtest/core';
import fs from 'fs';

const postSchema = z.object({
  title: z.string(),
  date: z.string(),
  author: z.string()
});

export async function getStaticProps({ params }) {
  const content = fs.readFileSync(`./content/${params.slug}.md`, 'utf-8');
  const doc = parseMarkdown(content);

  const data = await validateWithSchema(postSchema, doc.frontmatter, {
    throwOnError: true  // Fail build on invalid content
  });

  return { props: { post: { ...data, body: doc.body } } };
}

Universal

typescript
// Works with any framework or runtime
import { parseMarkdown, validateWithSchema, z } from '@fieldtest/core';

const schema = z.object({ title: z.string() });
const doc = parseMarkdown(markdown);
const result = await validateWithSchema(schema, doc.frontmatter);
const isValid = !('issues' in result);

Why Choose FieldTest?

🎯 Built for Modern Frameworks

Stop wrestling with framework-specific validation. FieldTest works the same way across Astro, Next.js, Remix, SvelteKit, and more.

📚 Standard Schema Foundation

Based on the emerging Standard Schema specification, ensuring your validation logic is future-proof and interoperable.

Performance Optimized

Designed to handle large content sites. Validates thousands of documents in seconds with minimal memory usage.

🔧 Developer Experience

Comprehensive TypeScript support, clear error messages, extensive documentation, and helpful tooling integrations.

OpenAPI Support

Use OpenAPI contracts to generate Zod schemas and validate request/response payloads.

Ready to Get Started?

🚀 Quick Start

Get up and running in less than 5 minutes with our comprehensive getting started guide.

Get Started →

📖 Learn by Example

Explore real-world examples and patterns for different frameworks and use cases.

Browse Examples →

🔍 API Reference

Comprehensive documentation of all functions, types, and configuration options.

View API →

Released under the MIT License.