# Class: NumberType

Number are plain JavaScript Number.

# 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
  • intVal flag that will allow only integer values
  • min minimum numerical value value that will be accepted
  • max maximum numeric value that will be accepted


const userSchema =  new Schema({
  age: Number,

# Hierarchy



# Constructors

# constructor

+ new NumberType(name: string, options?: CoreTypeOptions & NumberTypeOptions): NumberType

Overrides CoreType.constructor


Name Type
name string
options? CoreTypeOptions & NumberTypeOptions

Returns: NumberType

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

Overrides CoreType.sName

# Accessors

# default

get default(): unknown

Inherited from CoreType.default

Returns: unknown

# intVal

get intVal(): boolean

Returns: boolean

# max

get max(): number | NumberFunction | MinmaxOption | undefined

Returns: number | NumberFunction | MinmaxOption | undefined

# min

get min(): number | NumberFunction | MinmaxOption | undefined

Returns: number | NumberFunction | MinmaxOption | 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(): 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): unknown

Overrides CoreType.validate


Name Type
value unknown
strategy any

Returns: unknown