Skip to content
Open
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
6 changes: 3 additions & 3 deletions packages/core/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ export * from './util/zod-json-schema-compat.js';

// experimental exports
export * from './experimental/index.js';
export * from './validation/ajv-provider.js';
export * from './validation/cfworker-provider.js';
export * from './validators/ajv-provider.js';
export * from './validators/cfworker-provider.js';
/**
* JSON Schema validation
*
Expand Down Expand Up @@ -46,4 +46,4 @@ export * from './validation/cfworker-provider.js';
*/

// Core types only - implementations are exported via separate entry points
export type { JsonSchemaType, JsonSchemaValidator, jsonSchemaValidator, JsonSchemaValidatorResult } from './validation/types.js';
export type { JsonSchemaType, JsonSchemaValidator, jsonSchemaValidator, JsonSchemaValidatorResult } from './validators/types.js';
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ import { readFileSync } from 'node:fs';
import { join } from 'node:path';
import { vi } from 'vitest';

import { AjvJsonSchemaValidator } from '../../src/validation/ajv-provider.js';
import { CfWorkerJsonSchemaValidator } from '../../src/validation/cfworker-provider.js';
import type { JsonSchemaType } from '../../src/validation/types.js';
import { AjvJsonSchemaValidator } from '../../src/validators/ajv-provider.js';
import { CfWorkerJsonSchemaValidator } from '../../src/validators/cfworker-provider.js';
import type { JsonSchemaType } from '../../src/validators/types.js';

// Test with both AJV and CfWorker validators
// AJV validator will use default configuration with format validation enabled
Expand Down Expand Up @@ -334,8 +334,14 @@ describe('JSON Schema Validators', () => {
it('validates with allOf', () => {
const schema: JsonSchemaType = {
allOf: [
{ type: 'object', properties: { name: { type: 'string' } } },
{ type: 'object', properties: { age: { type: 'number' } } }
{
type: 'object',
properties: { name: { type: 'string' } }
},
{
type: 'object',
properties: { age: { type: 'number' } }
}
]
};
const validator = provider.getValidator(schema);
Expand Down Expand Up @@ -470,7 +476,10 @@ describe('JSON Schema Validators', () => {
type: 'object',
properties: {
name: { type: 'string' },
quantity: { type: 'integer', minimum: 1 }
quantity: {
type: 'integer',
minimum: 1
}
},
required: ['name', 'quantity']
}
Expand Down Expand Up @@ -553,7 +562,7 @@ describe('Missing dependencies', () => {
});

// Attempting to import ajv-provider should fail
await expect(import('../../src/validation/ajv-provider.js')).rejects.toThrow();
await expect(import('../../src/validators/ajv-provider.js')).rejects.toThrow();
});

it('should be able to import cfworker-provider when ajv is missing', async () => {
Expand All @@ -567,7 +576,7 @@ describe('Missing dependencies', () => {
});

// But cfworker-provider should import successfully
const cfworkerModule = await import('../../src/validation/cfworker-provider.js');
const cfworkerModule = await import('../../src/validators/cfworker-provider.js');
expect(cfworkerModule.CfWorkerJsonSchemaValidator).toBeDefined();

// And should work correctly
Expand All @@ -594,7 +603,7 @@ describe('Missing dependencies', () => {
});

// Attempting to import cfworker-provider should fail
await expect(import('../../src/validation/cfworker-provider.js')).rejects.toThrow();
await expect(import('../../src/validators/cfworker-provider.js')).rejects.toThrow();
});

it('should be able to import ajv-provider when @cfworker/json-schema is missing', async () => {
Expand All @@ -604,7 +613,7 @@ describe('Missing dependencies', () => {
});

// But ajv-provider should import successfully
const ajvModule = await import('../../src/validation/ajv-provider.js');
const ajvModule = await import('../../src/validators/ajv-provider.js');
expect(ajvModule.AjvJsonSchemaValidator).toBeDefined();

// And should work correctly
Expand All @@ -615,7 +624,7 @@ describe('Missing dependencies', () => {
});

it('should document that @cfworker/json-schema is required', () => {
const cfworkerProviderPath = join(__dirname, '../../src/validation/cfworker-provider.ts');
const cfworkerProviderPath = join(__dirname, '../../src/validators/cfworker-provider.ts');
const content = readFileSync(cfworkerProviderPath, 'utf-8');

expect(content).toContain('@cfworker/json-schema');
Expand Down
Loading