import { ObjectRawSchema } from "../schema-raw"; import { AnyOfObjectSchema } from "./anyof"; import { ArrayObjectSchema } from "./array"; import { BooleanObjectSchema } from "./boolean"; import { CustomObjectSchema } from "./custom"; import { NumberObjectSchema } from "./number"; import { RecursiveObjectSchema } from "./recursive"; import { AbstractObjectSchema, ObjectSchemaI } from "./schema"; import { StringObjectSchema } from "./string"; /** * Object schema */ export declare class ObjectSchema extends AbstractObjectSchema { /** * Schema from raw representation * @param raw Raw schema representation * @returns a new schema instance */ static fromRaw(raw: ObjectRawSchema): ObjectSchemaI; /** * Schema to represent the null value * @returns a new schema instance */ static null(): ObjectSchemaI; /** * Schema to represent the undefined value * @returns a new schema instance */ static undefined(): ObjectSchemaI; /** * Schema with custom tester and sanitizer * @returns a new schema instance */ static custom(): CustomObjectSchema; /** * Schema to represent a string * @returns a new schema instance */ static string(): StringObjectSchema; /** * Schema to represent a real number * @returns a new schema instance */ static number(): NumberObjectSchema; /** * Schema to represent an integer * @returns a new schema instance */ static integer(): NumberObjectSchema; /** * Schema to represent a boolean * @returns a new schema instance */ static boolean(): BooleanObjectSchema; /** * Schema to represent an array * @param itemsSchema Schema for the items of the array * @returns a new schema instance */ static array(itemsSchema: ObjectSchemaI): ArrayObjectSchema; /** * Schema for recursive references * @returns a new schema instance */ static recursive(): RecursiveObjectSchema; /** * Parent recursive reference * @returns a new schema instance */ static parent(): RecursiveObjectSchema; /** * The object should match one of the provided schemas * @param schemas List of schemas * @returns a new schema instance */ static anyOf(schemas: ObjectSchemaI[]): AnyOfObjectSchema; /** * Makes schema optional. This means undefined is allowed for test() * @param schema The schema * @returns a new schema instance */ static optional(schema: ObjectSchemaI): AnyOfObjectSchema; /** * Extends schema. For object schemas with pre-defined keys * @param schema Parent schema * @param ext Extension info * @returns Extended schema */ static extend(schema: ObjectSchemaI, ext: { [id: string]: { [prop: string]: ObjectSchemaI; }; }): ObjectSchemaI; /** * Schema for object type * @returns a new schema instance */ static create(): ObjectSchema; /** * Schema for object type (with a set of properties) * @param props Properties * @returns a new schema instance */ static object(props: { [propName: string]: ObjectSchemaI; }): ObjectSchema; /** * Schema for dictionary (key => value) * @param propsFilter Property filter * @param propsSchema Function to determine schema for properties * @returns a new schema instance */ static dict(propsFilter: (key: string) => boolean, propsSchema: (key: string) => ObjectSchemaI): ObjectSchema; private schema; /** * Constructor */ constructor(); /** * Add property to the object schema * @param propName The name of the property * @param schema The schema for the property * @returns self */ withProperty(propName: string, schema: ObjectSchemaI): ObjectSchema; /** * Sets required properties for the object * @param props Properties * @returns self */ withProperties(props: { [propName: string]: ObjectSchemaI; }): ObjectSchema; /** * Sets property filter for dynamic dictionaries * @param extraPropsFilter Function to filter the the propeties * @param extraPropsSchema Function to determine the schema to use in each case * @returns self */ withPropertyFilter(extraPropsFilter: (key: string) => boolean, extraPropsSchema: (key: string) => ObjectSchemaI): ObjectSchema; /** * Sets the ID for this schema to be referenced by its children * for recursion * @param id The identifier of the schema node * @returns self */ withId(id: string): ObjectSchema; }