UNPKG

@jsonjoy.com/json-type

Version:

High-performance JSON Pointer implementation

39 lines (38 loc) 1.65 kB
import type { Printable } from 'tree-dump/lib/types'; import type * as schema from '../../schema'; import type { SchemaExample } from '../../schema'; import { Value } from '../../value'; import type { BaseType, ModuleType } from '../types'; export declare abstract class AbsType<S extends schema.Schema> implements BaseType<S>, Printable { readonly schema: S; /** Default type system to use, if any. */ system?: ModuleType; readonly _validators: [validator: (value: unknown) => void, name?: string][]; constructor(schema: S); sys(system: ModuleType | undefined): this; getSystem(): ModuleType; kind(): S['kind']; value(data: schema.TypeOf<S>): Value<this>; /** * @todo Add ability to export the whole schema, including aliases. */ getSchema(): S; /** * Sets a custom runtime validator for this type. * * @param validator Function that validates the value of this type. * @returns `this` for chaining. */ validator(validator: (value: schema.TypeOf<S>) => void, name?: string): this; options(options: schema.Optional<Omit<S, 'kind'>>): this; title(title: string): this; intro(intro: string): this; description(description: string): this; default(value: schema.Schema['default']): this; example(value: schema.TypeOf<S>, title?: SchemaExample['title'], options?: Omit<SchemaExample, 'value' | 'title'>): this; getOptions(): schema.Optional<S>; alias<K extends string>(name: K): import("./AliasType").AliasType<K, this>; protected toStringTitle(): string; protected toStringOptions(): string; toString(tab?: string): string; }