Skip to content

satisfactory-dev/ajv-utilities

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Coverage Status Workflow Status

Installation

npm install --save-dev @satisfactory-dev/ajv-utilities

Usage

compile

import Ajv from 'ajv/dist/2020';
import {compile, FailedToCompileSchema} from '@satisfactory-dev/ajv-utilities';

const schema = {type: 'string'};

try {
	const check = compile(new Ajv(), schema);
} catch (err) {
	if (err instanceof FailedToCompileSchema) {
		console.error('failed to compile', err);
	} else {
		console.error('unknown error', err);
	}
}

esmify

import Ajv from 'ajv/dist/2020';
import standalone from 'ajv/dist/standalone';
import {compile, esmify} from '@satisfactory-dev/ajv-utilities';

const ajv = new Ajv();

await writeFile(
	'./standalone-validator.mjs',
	esmify(standalone(ajv, compile(ajv, schema)))
);