# 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

example

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

# Hierarchy

CoreType

DateType

# Constructors

# constructor

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

Overrides CoreType.constructor

Parameters:

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

Parameters:

Name Type Default
value any -
strategy CAST_STRATEGY CAST_STRATEGY.DEFAULT_OR_DROP

Returns: any


# checkRequired

checkRequired(): string | void

Inherited from CoreType.checkRequired

Returns: string | void


# checkValidator

checkValidator(value: unknown): void

Inherited from CoreType.checkValidator

Parameters:

Name Type
value unknown

Returns: void


# isEmpty

isEmpty(value: unknown): boolean

Inherited from CoreType.isEmpty

Parameters:

Name Type
value unknown

Returns: boolean


# isStrictStrategy

isStrictStrategy(strategy: VALIDATION_STRATEGY): boolean

Inherited from CoreType.isStrictStrategy

Parameters:

Name Type
strategy VALIDATION_STRATEGY

Returns: boolean


# validate

validate(value: unknown, strategy: any): unknown

Overrides CoreType.validate

Parameters:

Name Type
value unknown
strategy any

Returns: unknown