joiful
Version:
TypeScript Declarative Validation. Decorate your class properties to validate them using Joi.
59 lines (58 loc) • 2.28 kB
TypeScript
import * as Joi from 'joi';
import { TypedPropertyDecorator, AnyClass } from '../core';
import { ModifierProviders, JoifulOptions } from './common';
import { AnySchemaModifiers } from './any';
declare type AllowedPropertyTypes = any[];
export interface ArraySchemaModifiers extends AnySchemaModifiers {
/**
* Requires the array to be an exact length.
*/
exactLength(limit: number): this;
/**
* List the types allowed for the array values.
*/
items(type: Joi.Schema, ...types: Joi.Schema[]): this;
/**
* List the types allowed for the array values.
*/
items(itemsSchemaBuilder: (joi: typeof Joi) => Joi.Schema | Joi.Schema[]): this;
/**
* Specifies the maximum array length.
* @param limit The maximum length.
*/
max(limit: number): this;
/**
* Specifies the minimum array length.
* @param limit The minimum length.
*/
min(limit: number): this;
/**
* List the types in sequence order for the array values..
*/
ordered(type: Joi.Schema, ...types: Joi.Schema[]): this;
/**
* List the types in sequence order for the array values..
*/
ordered(itemsSchemaBuilder: (joi: typeof Joi) => Joi.Schema[]): this;
/**
* Allow single values to be checked against rules as if it were provided as an array.
* enabled can be used with a falsy value to go back to the default behavior.
*/
single(enabled?: boolean | any): this;
/**
* Allow this array to be sparse. enabled can be used with a falsy value to go back to the default behavior.
*/
sparse(enabled?: boolean | any): this;
/**
* Requires the array values to be unique.
*/
unique(): this;
}
export declare function getArraySchemaModifierProviders(getJoi: () => typeof Joi): ModifierProviders<Joi.ArraySchema, ArraySchemaModifiers>;
export interface ArraySchemaDecorator extends ArraySchemaModifiers, TypedPropertyDecorator<AllowedPropertyTypes> {
}
export interface ArrayPropertyDecoratorOptions {
elementClass?: AnyClass;
}
export declare const createArrayPropertyDecorator: (options: ArrayPropertyDecoratorOptions | undefined, joifulOptions: JoifulOptions) => import("./common").PropertyDecorator<any[], ArraySchemaModifiers>;
export {};