# 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

example

const userSchema =  new Schema({
  age: Number,
})

# Hierarchy

CoreType

NumberType

# Constructors

# constructor

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

Overrides CoreType.constructor

Parameters:

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

Parameters:

Name Type Default
value unknown -
strategy CAST_STRATEGY CAST_STRATEGY.DEFAULT_OR_DROP

Returns: unknown


# 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