Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions MIGRATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ fieldtest/
```typescript
import { validateWithSchema, marketingCopySchema } from '@watthem/fieldtest';
```
See [docs/getting-started.md](./docs/getting-started.md) for a guided Standard Schema example.


### For Markdown Processing

Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ npx turbo build
pnpm test
```

For a step-by-step Standard Schema walkthrough, see [docs/getting-started.md](./docs/getting-started.md).

## Package

`@watthem/fieldtest` bundles the core validation engine, schema registry, and framework integrations into a single, cohesive package:
Expand Down
66 changes: 66 additions & 0 deletions docs/getting-started.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# Getting Started

Follow these steps to validate content with FieldTest's Standard Schema.

## 1. Install

```bash
pnpm add @watthem/fieldtest
```

## 2. Define a schema

```ts
import type { StandardSchemaV1 } from '@watthem/fieldtest';

export const blogPostSchema: StandardSchemaV1 = {
version: '1',
name: 'blog-post',
fields: {
title: { type: 'string', required: true },
published: { type: 'boolean', required: true },
content: { type: 'string', required: true },
tags: { type: 'string', array: true }
}
};
```

## 3. Load and validate

```ts
import { loadUserSchema, validateWithSchema } from '@watthem/fieldtest';
import { blogPostSchema } from './schema';

const schema = loadUserSchema(blogPostSchema);

const doc = `
---
title: "Hello"
published: true
---
Content here
`;

const result = validateWithSchema(doc, schema);

if (result.valid) {
console.log('ok');
} else {
console.error(result.errors);
}
```

### No extra helpers

- `loadUserSchema` and `validateWithSchema` handle schema setup and validation.
- Tools like `zodToStandardSchema`, custom schema loaders, or manual validation pipelines are no longer necessary.

### Native replacements for removed helpers

These APIs replace earlier utilities that shipped with FieldTest:

- `loadUserSchema` replaces bespoke schema loading helpers.
- `validateWithSchema` replaces manual validation functions.

Using them keeps your code minimal and consistent across frameworks.

Loading