ajv-validator / ajv-validator/ajv-cli

Feature Request: compile to standalone TypeScript, or generate typings

Ouverte
#192 1 commentaire 25 réactions 0 personnes assignées Voir sur GitHub
Langage dominant
TypeScript
Étoiles
316
Forks
77
Métriques de merge des PR
Aucune PR mergée en 30 j

Description

I'm trying to validate JSON against a TypeScript interface. I used https://github.com/vega/ts-json-schema-generator to generate a JSON schema from the interface, then used `ajv-cli` to produce a standalone validator from the schema. The validator is an ES module with a default export function which takes the output of `JSON.parse` and returns true if the data is valid, or sets an `errors` property on the function and returns false otherwise.

I can write my own typings to describe this generated module, but it would be nice if the CLI could generate TypeScript code directly (with a flag like `-code-ts`), *or* add JSDoc annotations from which TypeScript can infer type information (at least for the one exported function), *or* create a .d.ts file describing the export(s) in the output directory (when run with a -o flag).

As an aside, if there's an easier way to get from what I have (TS interface) to what I want (runtime validation function), I'm happy to take other suggestions.

Guide de contribution

Aucun guide de contribution indexé pour ce dépôt

Évaluation

Cette issue n'a pas encore été évaluée.

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.