UNPKG

1.38 kBTypeScriptView Raw
1import { ReferenceObject, RequestBodyObject, SchemaObject, SchemasObject } from '@loopback/openapi-v3';
2import { RequestBody } from '..';
3import { ValidationOptions, ValueValidationOptions } from '../types';
4/**
5 * Check whether the request body is valid according to the provided OpenAPI schema.
6 * The JSON schema is generated from the OpenAPI schema which is typically defined
7 * by `@requestBody()`.
8 * The validation leverages AJV schema validator.
9 * @param body - The request body parsed from an HTTP request.
10 * @param requestBodySpec - The OpenAPI requestBody specification defined in `@requestBody()`.
11 * @param globalSchemas - The referenced schemas generated from `OpenAPISpec.components.schemas`.
12 * @param options - Request body validation options for AJV
13 */
14export declare function validateRequestBody(body: RequestBody, requestBodySpec?: RequestBodyObject, globalSchemas?: SchemasObject, options?: ValidationOptions): Promise<void>;
15/**
16 * Validate the value against JSON schema.
17 * @param value - The data value.
18 * @param schema - The JSON schema used to perform the validation.
19 * @param globalSchemas - Schema references.
20 * @param options - Value validation options.
21 */
22export declare function validateValueAgainstSchema(value: any, schema: SchemaObject | ReferenceObject, globalSchemas?: SchemasObject, options?: ValueValidationOptions): Promise<any>;