Skip to main content

Home > 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

ParameterTypeDescription
valuestring | 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).
minstring | number | null(Optional) Minimum value. Will only be used if config is not provided.
maxstring | number | null(Optional) Maximum value. Will only be used if config is not provided.
precisionstring | number | null(Optional) Precision for value. Will only be used if config is not provided.
validatorFieldNumberValidator | 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.
configFieldNumberConfig(Optional) A map of options used to configure the field. See the field creation documentation for a list of properties this parameter supports.