blockly > FieldVariable > getValidator
FieldVariable.getValidator() method
Gets the validation function for this field, or null if not set. Returns null if the variable is not set, because validators should not run on the initial setValue call, because the field won't be attached to a block and workspace at that point.
Signature:
getValidator(): FieldVariableValidator | null;
Returns:
FieldVariableValidator | null
Validation function, or null.
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2024-09-18 UTC.
[null,null,["Last updated 2024-09-18 UTC."],[[["The `getValidator()` method retrieves the validation function associated with a FieldVariable, which determines if a variable assignment is valid."],["It returns `null` if the variable isn't set or if the validation function hasn't been assigned, preventing validation during initial value setting."],["The returned validation function, if present, is of the `FieldVariableValidator` type and will be executed when variable assignments occur."]]],[]]