Skip to main content

blockly > FieldNumber > (constructor)

FieldNumber.(constructor)

Constructs a new instance of the FieldNumber class

Signature:

constructor(value?: string | number | typeof Field.SKIP_SETUP, min?: string | number | null, max?: string | number | null, precision?: string | number | null, validator?: FieldNumberValidator | null, config?: FieldNumberConfig);

Parameters

Parameter

Type

Description

value

string | number | typeof Field.SKIP_SETUP

(Optional) The initial value of the field. Should cast to a number. Defaults to 0. Also accepts Field.SKIP_SETUP if you wish to skip setup (only used by subclasses that want to handle configuration and setting the field value after their own constructors have run).

min

string | number | null

(Optional) Minimum value. Will only be used if config is not provided.

max

string | number | null

(Optional) Maximum value. Will only be used if config is not provided.

precision

string | number | null

(Optional) Precision for value. Will only be used if config is not provided.

validator

FieldNumberValidator | null

(Optional) A function that is called to validate changes to the field's value. Takes in a number & returns a validated number, or null to abort the change.

config

FieldNumberConfig

(Optional) A map of options used to configure the field. See the field creation documentation for a list of properties this parameter supports.