UNPKG

1.44 kBTypeScriptView Raw
1import { ParameterObject } from '@loopback/openapi-v3';
2/**
3 * A set of options to pass into the validator functions
4 */
5export type ValidationOptions = {
6 required?: boolean;
7};
8/**
9 * The context information that a validator needs
10 */
11export type ValidationContext = {
12 parameterSpec: ParameterObject;
13};
14/**
15 * Validator class provides a bunch of functions that perform
16 * validations on the request parameters and request body.
17 */
18export declare class Validator {
19 ctx: ValidationContext;
20 constructor(ctx: ValidationContext);
21 /**
22 * The validation executed before type coercion. Like
23 * checking absence.
24 *
25 * @param type - A parameter's type.
26 * @param value - A parameter's raw value from http request.
27 * @param opts - options
28 */
29 validateParamBeforeCoercion(value: string | object | undefined, opts?: ValidationOptions): void;
30 /**
31 * Check is a parameter required or not.
32 *
33 * @param opts
34 */
35 isRequired(opts?: ValidationOptions): boolean;
36 /**
37 * Return `true` if the value is empty, return `false` otherwise.
38 *
39 * @param value
40 */
41 isAbsent(value: any): boolean;
42 /**
43 * Return `true` if defined specification is for a url encoded Json object query parameter
44 *
45 * for url encoded Json object query parameters,
46 * schema is defined under content['application/json']
47 */
48 isUrlEncodedJsonParam(): boolean;
49}