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
↳
NumberType
Constructors
constructor
• new NumberType(name
, options?
)
Parameters
Name | Type |
---|---|
name | string |
options? | CoreTypeOptions & NumberTypeOptions |
Overrides
Defined in
schema/types/number-type.ts:40
Properties
name
• name: string
Inherited from
Defined in
schema/interfaces/schema.types.ts:51
options
• Optional
options: CoreTypeOptions
Inherited from
Defined in
typeName
• typeName: string
Inherited from
Defined in
schema/interfaces/schema.types.ts:51
sName
▪ Static
sName: string
= Number.name
Overrides
Defined in
schema/types/number-type.ts:43
Accessors
default
• get
default(): unknown
Returns
unknown
Inherited from
CoreType.default
Defined in
intVal
• get
intVal(): boolean
Returns
boolean
Defined in
schema/types/number-type.ts:55
max
• get
max(): undefined
| number
| NumberFunction
| MinmaxOption
Returns
undefined
| number
| NumberFunction
| MinmaxOption
Defined in
schema/types/number-type.ts:45
min
• get
min(): undefined
| number
| NumberFunction
| MinmaxOption
Returns
undefined
| number
| NumberFunction
| MinmaxOption
Defined in
schema/types/number-type.ts:50
required
• get
required(): boolean
| RequiredOption
| RequiredFunction
Returns
boolean
| RequiredOption
| RequiredFunction
Inherited from
CoreType.required
Defined in
validator
• get
validator(): undefined
| string
| ValidatorFunction
| ValidatorOption
Returns
undefined
| string
| ValidatorFunction
| ValidatorOption
Inherited from
CoreType.validator
Defined in
Methods
_checkMax
▸ Private
_checkMax(val
): string
Parameters
Name | Type |
---|---|
val | number |
Returns
string
Defined in
schema/types/number-type.ts:97
_checkMin
▸ Private
_checkMin(val
): string
Parameters
Name | Type |
---|---|
val | number |
Returns
string
Defined in
schema/types/number-type.ts:92
buildDefault
▸ buildDefault(): unknown
Returns
unknown
Inherited from
Defined in
cast
▸ cast(value
, strategy?
): unknown
Parameters
Name | Type | Default value |
---|---|---|
value | unknown | undefined |
strategy | CAST_STRATEGY | CAST_STRATEGY.DEFAULT_OR_DROP |
Returns
unknown
Overrides
Defined in
schema/types/number-type.ts:60
checkRequired
▸ checkRequired(): string
| void
Returns
string
| void
Inherited from
Defined in
checkValidator
▸ checkValidator(value
): void
Parameters
Name | Type |
---|---|
value | unknown |
Returns
void
Inherited from
Defined in
isEmpty
▸ isEmpty(value
): boolean
Parameters
Name | Type |
---|---|
value | unknown |
Returns
boolean
Inherited from
Defined in
isStrictStrategy
▸ isStrictStrategy(strategy
): boolean
Parameters
Name | Type |
---|---|
strategy | VALIDATION_STRATEGY |
Returns
boolean
Inherited from
Defined in
validate
▸ validate(value
, strategy
): unknown
Parameters
Name | Type |
---|---|
value | unknown |
strategy | any |
Returns
unknown