Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to use it with typescript for type safety? #89

Open
shahinghasemi opened this issue Feb 19, 2024 · 0 comments
Open

How to use it with typescript for type safety? #89

shahinghasemi opened this issue Feb 19, 2024 · 0 comments

Comments

@shahinghasemi
Copy link

shahinghasemi commented Feb 19, 2024

How can I use this package with type safety? Is there any way to extend JsonScehamType to includes the types for ajv-format? I couldn't find a way to do that.

import { JSONSchemaType } from 'ajv';

type Example = {
  age: number;
  name: string;
};
const sample: JSONSchemaType<Example> = {
  type: 'object',
  properties: {
    age: { type: ['integer'] },
    name: {type: ['string'], format: ['']}
  },
};

In the above example I want to apply some formats to name but it's type is string.

thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant