Skip to main content

Class: ArrayType

Defined in: schema/types/array-type.ts:25

Array type supports arrays of SchemaTypes and arrays of subdocuments.

Options

  • required flag to define if the field is mandatory
  • validator that will be applied to the field, allowed function, object or string with the name of the custom validator
  • default that will define the initial value of the field, allowed and value or function to generate it
  • immutable that will define this field as immutable. Ottoman prevents you from changing immutable fields if the schema as configure like strict

Example

const postSchemaDef = new Schema({
postTags: [String],
comments: [{ type: commentSchema, ref: 'Comment' }],
});

Extends

Constructors

Constructor

new ArrayType(name, itemType, options?): ArrayType

Defined in: schema/types/array-type.ts:26

Parameters

name

string

itemType

IOttomanType

options?

CoreTypeOptions

Returns

ArrayType

Overrides

CoreType.constructor

Properties

itemType

itemType: IOttomanType

Defined in: schema/types/array-type.ts:26


name

name: string

Defined in: schema/interfaces/schema.types.ts:51

Inherited from

CoreType.name


options?

optional options: CoreTypeOptions

Defined in: schema/types/core-type.ts:23

Inherited from

CoreType.options


typeName

typeName: string

Defined in: schema/interfaces/schema.types.ts:51

Inherited from

CoreType.typeName


sName

static sName: string = Array.name

Defined in: schema/types/array-type.ts:30

Overrides

CoreType.sName

Accessors

default

Get Signature

get default(): unknown

Defined in: schema/types/core-type.ts:39

Returns

unknown

Inherited from

CoreType.default


required

Get Signature

get required(): boolean | RequiredOption | RequiredFunction

Defined in: schema/types/core-type.ts:31

Returns

boolean | RequiredOption | RequiredFunction

Inherited from

CoreType.required


validator

Get Signature

get validator(): undefined | string | ValidatorFunction | ValidatorOption

Defined in: schema/types/core-type.ts:35

Returns

undefined | string | ValidatorFunction | ValidatorOption

Inherited from

CoreType.validator

Methods

buildDefault()

buildDefault(): unknown

Defined in: schema/types/core-type.ts:43

Returns

unknown

Inherited from

CoreType.buildDefault


cast()

cast(value, strategy): unknown

Defined in: schema/types/array-type.ts:32

Parameters

value

unknown

strategy

CAST_STRATEGY = CAST_STRATEGY.DEFAULT_OR_DROP

Returns

unknown

Overrides

CoreType.cast


checkRequired()

checkRequired(): string | void

Defined in: schema/types/core-type.ts:62

Returns

string | void

Inherited from

CoreType.checkRequired


checkValidator()

checkValidator(value): void

Defined in: schema/types/core-type.ts:71

Parameters

value

unknown

Returns

void

Inherited from

CoreType.checkValidator


isEmpty()

isEmpty(value): boolean

Defined in: schema/types/core-type.ts:75

Parameters

value

unknown

Returns

boolean

Inherited from

CoreType.isEmpty


isStrictStrategy()

isStrictStrategy(strategy): boolean

Defined in: schema/types/core-type.ts:79

Parameters

strategy

VALIDATION_STRATEGY

Returns

boolean

Inherited from

CoreType.isStrictStrategy


validate()

validate(value, strict): unknown

Defined in: schema/types/array-type.ts:39

Parameters

value

unknown

strict

boolean = true

Returns

unknown

Overrides

CoreType.validate