@satisfactory-dev/ajv-utilities
TypeScript icon, indicating that this package has built-in type declarations

0.1.1 • Public • Published

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)))
);

Dependents (1)

Package Sidebar

Install

npm i @satisfactory-dev/ajv-utilities

Weekly Downloads

23

Version

0.1.1

License

Apache-2.0

Unpacked Size

15 kB

Total Files

9

Last publish

Collaborators

  • signpostmarv