Class: DateType
Defined in: schema/types/date-type.ts:38
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
})
Extends
Constructors
Constructor
new DateType(
name
,options?
):DateType
Defined in: schema/types/date-type.ts:39
Parameters
name
string
options?
DateTypeOptions
& CoreTypeOptions
Returns
DateType
Overrides
Properties
name
name:
string
Defined in: schema/interfaces/schema.types.ts:51
Inherited from
options?
optional
options:CoreTypeOptions
Defined in: schema/types/core-type.ts:23
Inherited from
typeName
typeName:
string
Defined in: schema/interfaces/schema.types.ts:51
Inherited from
sName
static
sName:string
=Date.name
Defined in: schema/types/date-type.ts:43
Overrides
Accessors
default
Get Signature
get default():
unknown
Defined in: schema/types/core-type.ts:39
Returns
unknown
Inherited from
max
Get Signature
get max():
undefined
|Date
|DateOption
|DateFunction
Defined in: schema/types/date-type.ts:53
Returns
undefined
| Date
| DateOption
| DateFunction
min
Get Signature
get min():
undefined
|Date
|DateOption
|DateFunction
Defined in: schema/types/date-type.ts:45
Returns
undefined
| Date
| DateOption
| DateFunction
required
Get Signature
get required():
boolean
|RequiredOption
|RequiredFunction
Defined in: schema/types/core-type.ts:31
Returns
boolean
| RequiredOption
| RequiredFunction
Inherited from
validator
Get Signature
get validator():
undefined
|string
|ValidatorFunction
|ValidatorOption
Defined in: schema/types/core-type.ts:35
Returns
undefined
| string
| ValidatorFunction
| ValidatorOption
Inherited from
Methods
buildDefault()
buildDefault():
undefined
|Date
Defined in: schema/types/date-type.ts:61
Returns
undefined
| Date
Overrides
cast()
cast(
value
,strategy
):any
Defined in: schema/types/date-type.ts:69
Parameters
value
any
strategy
CAST_STRATEGY
= CAST_STRATEGY.DEFAULT_OR_DROP
Returns
any
Overrides
checkRequired()
checkRequired():
string
|void
Defined in: schema/types/core-type.ts:62
Returns
string
| void
Inherited from
checkValidator()
checkValidator(
value
):void
Defined in: schema/types/core-type.ts:71
Parameters
value
unknown
Returns
void
Inherited from
isEmpty()
isEmpty(
value
):boolean
Defined in: schema/types/core-type.ts:75
Parameters
value
unknown
Returns
boolean
Inherited from
isStrictStrategy()
isStrictStrategy(
strategy
):boolean
Defined in: schema/types/core-type.ts:79
Parameters
strategy
Returns
boolean
Inherited from
validate()
validate(
value
,strategy
):unknown
Defined in: schema/types/date-type.ts:77
Parameters
value
unknown
strategy
any
Returns
unknown