import { IContainer } from '../di/resolvers'; import { Schema } from "./schema"; import { IRequestContext } from "../pipeline/common"; import { ISchemaTypeDefinition } from './schemaType'; /** * Domain model */ export declare class Domain { name: string; private container; private _schemas; private static types; constructor(name: string, container: IContainer); /** * Declare a new type or validator */ static addType(name: string, type: ISchemaTypeDefinition): void; getScalarTypeOf(source: ISchemaTypeDefinition | string): string; getType(name: string): ISchemaTypeDefinition; addSchema(schema: Schema): void; /** * Get a registered schema by name * Throws an exception if not exists * @param {string} schema name * @returns a schema */ getSchema(name: string | Function, optional?: boolean): Schema; /** * Get all schemas * * @readonly */ readonly schemas: Schema[]; /** * Validate an object * @param val : Object to validate * @param schemaName : schema to use (default=current schema) * @returns Array : A list of errors */ validate(ctx: IRequestContext, val: any, schemaName?: string | Schema): Promise | { [propertyName: string]: string; }; getSchemaFromObject(schemaName?: string | Schema, val?: any): Schema; }