# Class: DateType

Date are plain JavaScript Date.

# 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
  • min minimum date value that will be accepted
  • max maximum date value that will be accepted


const userSchema =  new Schema({
  birthday: { type: Date, min: '1990-12-31', max: new Date() },
  hired: Schema.Types.Date

# Hierarchy



# Constructors

# constructor

+ new DateType(name: string, options?: DateTypeOptions & CoreTypeOptions): DateType

Overrides CoreType.constructor


Name Type
name string
options? DateTypeOptions & CoreTypeOptions

Returns: DateType

# Properties

# 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 = Date.name

Overrides CoreType.sName

# Accessors

# default

get default(): unknown

Inherited from CoreType.default

Returns: unknown

# max

get max(): Date | DateOption | DateFunction | undefined

Returns: Date | DateOption | DateFunction | undefined

# min

get min(): Date | DateOption | DateFunction | undefined

Returns: Date | DateOption | DateFunction | undefined

# 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(): Date | undefined

Overrides CoreType.buildDefault

Returns: Date | undefined

# cast

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

Overrides IOttomanType.cast


Name Type Default
value any -

Returns: any

# 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): unknown

Overrides CoreType.validate


Name Type
value unknown
strategy any

Returns: unknown