# Class: ArrayType

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


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

# Hierarchy



# Constructors

# constructor

+ new ArrayType(name: string, itemType: IOttomanType, options?: CoreTypeOptions): ArrayType

Overrides CoreType.constructor


Name Type
name string
itemType IOttomanType
options? CoreTypeOptions

Returns: ArrayType

# Properties

# itemType

itemType: IOttomanType

# name

name: string

Inherited from IOttomanType.name

# Optional options

options? : CoreTypeOptions

Inherited from CoreType.options

# typeName

typeName: string

Inherited from IOttomanType.typeName

# Static sName

sName: string = Array.name

Overrides CoreType.sName

# Accessors

# default

get default(): unknown

Inherited from CoreType.default

Returns: unknown

# required

get required(): boolean | RequiredOption | RequiredFunction

Inherited from CoreType.required

Returns: boolean | RequiredOption | RequiredFunction

# validator

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

Inherited from CoreType.validator

Returns: ValidatorOption | ValidatorFunction | string | undefined

# Methods

# buildDefault

buildDefault(): unknown

Inherited from CoreType.buildDefault

Returns: unknown

# cast

cast(value: unknown, strategy: CAST_STRATEGY): unknown

Overrides IOttomanType.cast


Name Type Default
value unknown -

Returns: unknown

# checkRequired

checkRequired(): string | void

Inherited from CoreType.checkRequired

Returns: string | void

# checkValidator

checkValidator(value: unknown): void

Inherited from CoreType.checkValidator


Name Type
value unknown

Returns: void

# isEmpty

isEmpty(value: unknown): boolean

Inherited from CoreType.isEmpty


Name Type
value unknown

Returns: boolean

# isStrictStrategy

isStrictStrategy(strategy: VALIDATION_STRATEGY): boolean

Inherited from CoreType.isStrictStrategy


Name Type

Returns: boolean

# validate

validate(value: unknown, strict: boolean): unknown

Overrides CoreType.validate


Name Type Default
value unknown -
strict boolean true

Returns: unknown