# Class: EmbedType

EmbedType will allow declaration of path as another schema, set type to the sub-schema's instance.

# Options

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


const userSchema = new Schema({
  name: String,
  email: Schema.Types.String,
  createAt: Date,

const schema = new Schema({
  user: userSchema

You can also use a JavaScript plain Object as value for an EmbedType. Therefore the below example will behave the same as the example above.

const schema = new Schema({
 user: {
   name: String,
   email: String,
   createAt: Date,

tip EmbedType will allow you to easily reuse existing schemas into new ones using composition.

# Hierarchy



# Constructors

# constructor

+ new EmbedType(name: string, schema: Schema, options?: CoreTypeOptions): EmbedType

Overrides CoreType.constructor


Name Type
name string
schema Schema
options? CoreTypeOptions

Returns: EmbedType

# Properties

# name

name: string

Inherited from IOttomanType.name

# Optional options

options? : CoreTypeOptions

Inherited from CoreType.options

# schema

schema: Schema

# typeName

typeName: string

Inherited from IOttomanType.typeName

# Static sName

sName: string = "Embed"

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, strategy: any): any

Overrides CoreType.validate


Name Type
value unknown
strategy any

Returns: any