Skip to main content

Type Alias: FieldValidator<T>

type FieldValidator<T> = (newValue) => T | null | undefined;

Defined in: packages/blockly/core/field.ts:62

A function that is called to validate changes to the field's value before they are set.

Type Parameters

Type ParameterDefault type
Tany

Parameters

ParameterTypeDescription
newValueTThe value to be validated.

Returns

T | null | undefined

One of three instructions for setting the new value: T, null, or undefined.

  • T to set this function's returned value instead of newValue.

  • null to invoke doValueInvalid_ and not set a value.

  • undefined to set newValue as is.

See

https://docs.blockly.com/guides/create-custom-blocks/fields/validators/#return-values