UNPKG

@avonjs/avonjs

Version:

A fluent Node.js API generator.

72 lines (71 loc) 2.12 kB
import { type AnySchema } from 'joi'; import type { OpenAPIV3 } from 'openapi-types'; import type { AnyValue, FilledCallback, Model, OpenApiSchema, Optional } from '../Contracts'; import type AvonRequest from '../Http/Requests/AvonRequest'; import Field from './Field'; export default class Array extends Field { /** * The validation rules callback for creation and updates. */ protected rulesSchema: AnySchema; /** * The validation rules callback for creation. */ protected creationRulesSchema: AnySchema; /** * The validation rules callback for updates. */ protected updateRulesSchema: AnySchema; /** * Minimum length of the array */ protected minItems?: number; /** * Maximum length of the array */ protected maxItems?: number; /** * Indicates items schema. */ protected itemsSchema: OpenAPIV3.SchemaObject; /** * Hydrate the given attribute on the model based on the incoming request. */ protected fillAttributeFromRequest<TModel extends Model>(request: AvonRequest, requestAttribute: string, model: TModel, attribute: string): Optional<FilledCallback>; /** * Specifies the exact number of items in the array. */ length(limit?: number): this; /** * Specifies the minimum number of items in the array. */ min(minItems?: number): this; /** * Specifies the maximum number of items in the array. */ max(maxItems?: number): this; /** * Mutate the field value for response. */ getMutatedValue(request: AvonRequest, value: AnyValue): AnyValue[]; /** * Determine field is filterable or not. */ isFilterable(): boolean; /** * Determine field is orderable or not. */ isOrderable(): boolean; /** * Specify items schema. */ items(itemsSchema: OpenAPIV3.SchemaObject): this; /** * Get the value considered as null. */ nullValue(): AnyValue; /** * Get the base swagger-ui schema. */ protected baseSchema(request: AvonRequest): OpenApiSchema; }